﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.Common;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Von.Library;
using Von.Web.Apis;
using Von.Web.Datas;
using Von.Web.Framework;
using Von.Web.Models;
using Von.Web.Structs;
using Von.Web.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Von.Web.Interfaces;
using System.Security.Cryptography;

#region "模块声明"
namespace Von.Web
{
    /// <summary>
    /// 应用声明
    /// </summary>
    public class Statement : AssemblyDefinationBase
    {
        public static PortalDefination App = new PortalDefination() { AssemlyName = "WebCore" };
        private static StatementDBAccessionBase _Accession = null;
        public static StatementDBAccessionBase Accession
        {
            get
            {
                if (_Accession == null)
                {
                    _Accession = (StatementDBAccessionBase)Reflection.CreateObject(App.Prefix + "WebCoreDataAccess", "Von.Web.Datas." + App.Prefix + "Accession");
                    _Accession.AppDefination = App;
                }
                return _Accession;
            }
        }
        //    = (ApplicationDBAccessionBase)Von.Web.Framework.Reflection.CreateObject(Runtime.AppPath + "Bin\\" + App.Prefix + App.AssemlyName + "DataAccess.dll", "Von.Web.Datas.SqlAccession");
        public override ApplicationDefinationBase AppDefination { get => Statement.App; }
        //public override StatementDBAccessionBase DBAccession { get { return Statement.Accession; } }
        /// <summary>
        /// 平台模块加载函数
        /// </summary>
        /// <returns></returns>
        public override bool Init()
        {
            Von.Web.Framework.Runtime.RegistService(new AppThread());   //注册系统服务
            Runtime.RegistComponent(new Components.ScreenLabel());      //注册系统大屏组件
            Runtime.RegistComponent(new Components.ScreenClock());      //注册系统大屏组件
            Runtime.RegistComponent(new Components.ScreenDigitalClock());      //注册系统大屏组件
            //regist Listener
            //regist Service
            //Init self
            return true;
        }

        private static SMSBase _SystemSms = null;
        public static SMSBase SystemSms
        {
            get
            {
                if (_SystemSms == null)
                {
                    if (!App.AppSetting.ContainsKey("SystemSms")) return null;
                    string[] SystemSms = App.AppSetting["SystemSms"].ToString().Split('=');
                    _SystemSms = SMSBase.GetSMSInstance(SystemSms[0]);
                    _SystemSms.RegistProvider("SystemSms", SystemSms[1]);
                }
                return _SystemSms;
            }
        }
    }
    /// <summary>
    /// 应用定义
    /// </summary>
    public class PortalDefination : ApplicationDefinationBase
    {
        #region Definition of author
        /// <summary>版本信息</summary>
        [LocalDisplay("版本信息", "模块信息")]
        public override int Version { get => 3; }
        /// <summary>作者</summary>
        [LocalDisplay("作者", "模块信息")]
        public override string Author { get => "james von"; }
        /// <summary>版权说明</summary>
        [LocalDisplay("版权说明", "模块信息")]
        public override string Copyright { get => "Copyright by jamesvon @2022"; }
        /// <summary>数据访问层命名空间</summary>
        [LocalDisplay("数据访问层命名空间", "模块信息")]
        public override string DBAccessNameSpacec { get => "Von.Web.Datas"; }
        private DateTime? ValidDate = null;
        private List<string> ValiedAction = new List<string>();
        /// <summary>应用是否有效判断</summary>
        public override bool CheckModuleAvailed(string ModuleName, Guid ActionIdx)
        {
            if (ValidDate == null)
            {
                string key = ID.ToString();
                Byte[] toEncryptArray = Encoding.UTF8.GetBytes(Cert);
                RijndaelManaged rm = new RijndaelManaged();
                while (key.Length < rm.Key.Length) key += key;
                rm.Key = Encoding.UTF8.GetBytes((key).Substring(0, rm.Key.Length));
                rm.Mode = CipherMode.ECB;
                rm.Padding = PaddingMode.PKCS7;
                Byte[] toDecryptArray = Convert.FromBase64String(Cert);
                ICryptoTransform cTransform = rm.CreateDecryptor();
                Byte[] resultArray = cTransform.TransformFinalBlock(toDecryptArray, 0, toDecryptArray.Length);
                JObject certJson = JObject.Parse(Encoding.UTF8.GetString(resultArray));
                if (certJson.Value<bool>("checkAviledate")) ValidDate = certJson.Value<DateTime>("aviledate"); else ValidDate = DateTime.MaxValue;
                ValiedAction.Clear();
                foreach (var j in (JArray)certJson["module"])
                {
                    ValiedAction.Add(j.ToString());
                }
            }
            if (DateTime.Now > ValidDate) return false;
            var a = ValiedAction.FirstOrDefault(v => v.EndsWith(ModuleName + ".*", StringComparison.OrdinalIgnoreCase));
            if (a != null) return true;
            a = ValiedAction.FirstOrDefault(v => v.EndsWith(ModuleName + "." + ActionIdx.ToString(), StringComparison.OrdinalIgnoreCase));
            if (a != null) return true;
            return false;
        }
        #endregion
        public override ApplicationDBAccessionBase DBAccession { get { return Statement.Accession; } }
    }
}
#endregion

#region 系统关键信息
namespace Von.Web
{
    namespace Apis
    {
        /// <summary>系统应用 信息接口声明</summary>
        public interface ApplicationInterface
        {
            #region "Properties"
            /// <summary>序号</summary>
            Guid ID { get; set; }
            /// <summary>应用名称</summary>
            string AppName { get; set; }
            /// <summary>应用标题</summary>
            string AppTitle { get; set; }
            /// <summary>程序集</summary>
            string AssemlyName { get; set; }
            /// <summary>工作路径</summary>
            string WorkPath { get; set; }
            /// <summary>表前缀</summary>
            string Qualifier { get; set; }
            /// <summary>访问前缀</summary>
            string Prefix { get; set; }
            /// <summary>数据库访问者</summary>
            string Owner { get; set; }
            /// <summary>日志级别</summary>
            int LogClass { get; set; }
            #endregion
        }
    }
    namespace Structs
    {
        /// <summary>系统应用 信息结构声明</summary>
        /// <seealso cref="Von.Web.Apis.ApplicationInterface"/>
        public class ApplicationInfo : ApplicationInterface
        {
            #region "Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "系统应用")]
            public Guid ID { get; set; } = Guid.NewGuid();
            /// <summary>应用名称</summary>
            [LocalDisplay("应用名称", "系统应用")]
            public string AppName { get; set; } = "";
            /// <summary>应用标题</summary>
            [LocalDisplay("应用标题", "系统应用")]
            public string AppTitle { get; set; } = "";
            /// <summary>程序集</summary>
            [LocalDisplay("程序集", "系统应用")]
            public string AssemlyName { get; set; } = "";
            /// <summary>工作路径</summary>
            [LocalDisplay("工作路径", "系统应用")]
            public string WorkPath { get; set; } = "";
            /// <summary>表前缀</summary>
            [LocalDisplay("表前缀", "系统应用")]
            public string Qualifier { get; set; } = "";
            /// <summary>访问程序集前缀</summary>
            [LocalDisplay("访问前缀", "系统应用")]
            public string Prefix { get; set; } = "";
            /// <summary>数据库访问者</summary>
            [LocalDisplay("数据库访问者", "系统应用")]
            public string Owner { get; set; } = "";
            /// <summary>日志级别</summary>
            [LocalDisplay("日志级别", "系统应用")]
            public int LogClass { get; set; } = 0;
            #endregion
        }
    }
    namespace Models
    {
        /// <summary>系统应用 信息模块声明（含大字段）</summary>
        /// <seealso cref="Von.Web.Structs.ApplicationInfo"/>
        public class ApplicationModel : ApplicationInfo
        {
            /// <summary>模块证书</summary>
            public string Cert { get; set; }
            /// <summary>系统参数</summary>
            public JObject AppSetting { get; set; } = new JObject();
        }
    }
}
#endregion
#region 数据库表字典
namespace Von.Web
{
    namespace Structs
    {
        #region "数据库表字典信息类声明"
        /// <summary>数据库表字典 信息类</summary>
        public class DBTableInfo
        {
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "数据库表字典")]
            public Guid ID { get; set; }
            /// <summary>表名称</summary>
            [LocalDisplay("表名称", "数据库表字典")]
            public string TableCode { get; set; }
            /// <summary>中文名称</summary>
            [LocalDisplay("中文名称", "数据库表字典")]
            public string TableName { get; set; }
            /// <summary>所属模块</summary>
            [LocalDisplay("所属应用", "数据库表字典")]
            public Guid AppIdx { get; set; }
            /// <summary>支持历史</summary>
            [LocalDisplay("支持历史", "数据库表字典")]
            public bool SupportHistory { get; set; }
            /// <summary>支持流程</summary>
            [LocalDisplay("支持流程", "数据库表字典")]
            public bool SupportFlow { get; set; }
            /// <summary>支持排序</summary>
            [Required]
            [LocalDisplay("支持排序", "数据库表字典")]
            public bool SupportOrder { get; set; }
            /// <summary>支持树形</summary>
            [LocalDisplay("支持树形", "数据库表字典")]
            public bool SupportTree { get; set; }
            /// <summary>支持任务</summary>
            [LocalDisplay("支持任务", "数据库表字典")]
            public bool SupportTask { get; set; }
            /// <summary>支持核押</summary>
            [LocalDisplay("支持核押", "数据库表字典")]
            public bool SupportCRC { get; set; }
            #endregion
        }
        #endregion
        #region "数据库表字段字典信息类声明"
        /// <summary>数据库表字段字典 信息类</summary>
        public class DBFieldInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public DBFieldInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="TableIdx">表索引</param>
            /// <param name="FieldName">字段标题</param>
            /// <param name="FieldCode">字段名</param>
            /// <param name="FieldType">字段类型</param>
            /// <param name="IsPrimaryKey">是否是主键</param>
            public DBFieldInfo(Guid ID, Guid TableIdx, string FieldName, string FieldCode, string FieldType, bool IsPrimaryKey)
            {
                this.ID = ID;
                this.TableIdx = TableIdx;
                this.FieldName = FieldName;
                this.FieldCode = FieldCode;
                this.FieldType = FieldType;
                this.IsPrimaryKey = IsPrimaryKey;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "数据库表字段字典")]
            public Guid ID { get; set; }
            /// <summary>表索引</summary>
            [Required]
            [LocalDisplay("表索引", "数据库表字段字典")]
            public Guid TableIdx { get; set; }
            /// <summary>字段标题</summary>
            [LocalDisplay("字段标题", "数据库表字段字典")]
            public string FieldName { get; set; }
            /// <summary>字段名</summary>
            [LocalDisplay("字段名", "数据库表字段字典")]
            public string FieldCode { get; set; }
            /// <summary>字段类型</summary>
            [LocalDisplay("字段类型", "数据库表字段字典")]
            public string FieldType { get; set; }
            /// <summary>是否是主键</summary>
            [LocalDisplay("是否是主键", "数据库表字段字典")]
            public bool IsPrimaryKey { get; set; }
            #endregion
        }
        #endregion
        #region "应用表索引信息类声明"
        /// <summary>应用表索引 信息类</summary>
        public class DBIndexInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public DBIndexInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="TableIdx">表结构索引</param>
            /// <param name="IndexName">索引标题</param>
            /// <param name="IndexCode">索引名称</param>
            /// <param name="FieldSet">索引字段集合</param>
            public DBIndexInfo(Guid ID, Guid TableIdx, string IndexName, string IndexCode, string FieldSet)
            {
                this.ID = ID;
                this.TableIdx = TableIdx;
                this.IndexName = IndexName;
                this.IndexCode = IndexCode;
                this.FieldSet = FieldSet;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "应用表索引")]
            public Guid ID { get; set; }
            /// <summary>表结构索引</summary>
            [Required]
            [LocalDisplay("表结构索引", "应用表索引")]
            public Guid TableIdx { get; set; }
            /// <summary>索引标题</summary>
            [LocalDisplay("索引标题", "应用表索引")]
            public string IndexName { get; set; }
            /// <summary>索引名称</summary>
            [LocalDisplay("索引名称", "应用表索引")]
            public string IndexCode { get; set; }
            /// <summary>索引字段集合</summary>
            [LocalDisplay("索引字段集合", "应用表索引")]
            public string FieldSet { get; set; }
            #endregion
        }
        #endregion
        #region "表结构外键信息类声明"
        /// <summary>表结构外键 信息类</summary>
        public class DBLinkInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public DBLinkInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="ForeignKeyName">外键标题</param>
            /// <param name="ForeignKeyCode">外键名称</param>
            /// <param name="ParentFieldIdx">父表字段索引</param>
            /// <param name="ChildFieldIdx">子表字段索引</param>
            public DBLinkInfo(int ID, string ForeignKeyName, string ForeignKeyCode, Guid ParentFieldIdx, Guid ChildFieldIdx)
            {
                this.ID = ID;
                this.ForeignKeyName = ForeignKeyName;
                this.ForeignKeyCode = ForeignKeyCode;
                this.ParentFieldIdx = ParentFieldIdx;
                this.ChildFieldIdx = ChildFieldIdx;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "表结构外键")]
            public int ID { get; set; }
            /// <summary>外键标题</summary>
            [LocalDisplay("外键标题", "表结构外键")]
            public string ForeignKeyName { get; set; }
            /// <summary>外键名称</summary>
            [LocalDisplay("外键名称", "表结构外键")]
            public string ForeignKeyCode { get; set; }
            /// <summary>父表字段索引</summary>
            [Required]
            [LocalDisplay("父表字段索引", "表结构外键")]
            public Guid ParentFieldIdx { get; set; }
            /// <summary>子表字段索引</summary>
            [Required]
            [LocalDisplay("子表字段索引", "表结构外键")]
            public Guid ChildFieldIdx { get; set; }
            #endregion
        }
        #endregion
    }
    namespace Models
    {
        public class DBFieldModel : DBFieldInfo
        {
            public Guid ParentFieldIdx { get; set; }
            public string LinkInfo { get; set; }
        }
        public class FieldManageModel
        {
            public List<DBFieldModel> Fields;
            public List<DBIndexInfo> Indexes;
        }
        public class DBIndexMode : DBIndexInfo
        {
            public async Task ConvertFields()
            {
                fields = new KeyValueObjectCollection();
                DBFieldTask task = new DBFieldTask();
                List<DBFieldInfo> lst = await task.ListByTable<DBFieldInfo>(TableIdx);
                foreach (DBFieldInfo info in lst)
                {
                    fields.Add(new KeyValueObject(info.FieldCode, info.FieldName, ("," + FieldSet + ",").IndexOf("," + info.FieldCode + ",") >= 0));
                }
            }
            public KeyValueObjectCollection fields { get; set; }
        }
    }
    namespace Tasks
    {
        #region "数据库表字典信息基础控制类声明"
        /// <summary>数据库表字典 控制类</summary>
        /// <seealso cref="Von.Web.Models.DBTableInfo"/>
        public class DBTableTask
        {
            DBTableAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public DBTableTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<DBTableAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, DBTableInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.TableCode = reader.GetString(1);  //表名称
                info.TableName = reader.GetString(2);  //中文名称
                info.AppIdx = reader.GetGuid(3);  //所属应用
                info.SupportHistory = reader.GetBoolean(4);  //支持历史
                info.SupportFlow = reader.GetBoolean(5);  //支持流程
                info.SupportOrder = reader.GetBoolean(6);  //支持排序
                info.SupportTree = reader.GetBoolean(7);  //支持树形
                info.SupportTask = reader.GetBoolean(8);  //支持任务
                info.SupportCRC = reader.GetBoolean(9);  //支持核押
            }
            /// <summary>检验DBTable信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : DBTableInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_DataDictionary 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByDataDictionary<T>(Guid ID) where T : DBTableInfo, new()
            {
                IDataReader reader = dbAccess.GetByDataDictionary(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 数据库表字典 信息</summary>
            public async Task<List<T>> List<T>() where T : DBTableInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 Idx_DataDictionary 提取信息</summary>
            /// <param name="SupportOrder">支持排序</param>
            public async Task<List<T>> ListByIdx_DataDictionary<T>(bool SupportOrder) where T : DBTableInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByIdx_DataDictionary(SupportOrder);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_TA_REF_APPLICATION 提取信息</summary>
            public async Task<List<T>> ListByApp<T>(Guid ID) where T : DBTableInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByApp(ID);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加DBTable信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : DBTableInfo, new()
            {
                return dbAccess.Add(info.ID, info.TableCode, info.TableName, info.AppIdx, info.SupportHistory, info.SupportFlow, info.SupportOrder, info.SupportTree, info.SupportTask, info.SupportCRC) > 0;
            }
            /// <summary>修改DBTable信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : DBTableInfo, new()
            {
                return dbAccess.Edit(info.ID, info.TableCode, info.TableName, info.AppIdx, info.SupportHistory, info.SupportFlow, info.SupportOrder, info.SupportTree, info.SupportTask, info.SupportCRC) > 0;
            }
            /// <summary>根据PK_DataDictionary删除DBTable信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_TA_REF_APPLICATION删除DBTable信息</summary>
            ///<param name="ID">序号</param>
            public async Task<bool> DelID(Guid ID)
            {
                return dbAccess.DelID(ID) > 0;
            }

        }
        #endregion
        #region "数据库表字段字典信息基础控制类声明"
        /// <summary>数据库表字段字典 控制类</summary>
        /// <seealso cref="Von.Web.Models.DBFieldInfo"/>
        public class DBFieldTask
        {
            protected DBFieldAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public DBFieldTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<DBFieldAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, DBFieldInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.TableIdx = reader.GetGuid(1);  //表索引
                info.FieldName = reader.GetString(2);  //字段标题
                info.FieldCode = reader.GetString(3);  //字段名
                info.FieldType = reader.GetString(4);  //字段类型
                info.IsPrimaryKey = reader.GetBoolean(5);  //是否是主键
            }
            /// <summary>检验DBField信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : DBFieldInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_DBField 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByDBField<T>(Guid ID) where T : DBFieldInfo, new()
            {
                IDataReader reader = dbAccess.GetByDBField(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 数据库表字段字典 信息</summary>
            public async Task<List<T>> List<T>() where T : DBFieldInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 TABLE 提取模型列表</summary>
            public async Task<List<DBFieldModel>> ListModelByTable(Guid TableIdx)
            {
                List<DBFieldModel> list = new List<DBFieldModel>();
                IDataReader reader = dbAccess.ListModelByTable(TableIdx);
                while (reader.Read())
                {
                    DBFieldModel info = new DBFieldModel();
                    setInfoValue(reader, info);
                    info.ParentFieldIdx = reader.IsDBNull(6) ? Guid.Empty : reader.GetGuid(6);    //关联字段
                    info.LinkInfo = reader.IsDBNull(7) ? "" : reader.GetString(7);        //关联描述  
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_FIELD_REF_TABLE 提取信息</summary>
            public async Task<List<T>> ListByTable<T>(Guid TableIdx) where T : DBFieldInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByTable(TableIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加DBField信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : DBFieldInfo, new()
            {
                return dbAccess.Add(info.ID, info.TableIdx, info.FieldName, info.FieldCode, info.FieldType, info.IsPrimaryKey) > 0;
            }
            /// <summary>修改DBField信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : DBFieldInfo, new()
            {
                return dbAccess.Edit(info.ID, info.TableIdx, info.FieldName, info.FieldCode, info.FieldType, info.IsPrimaryKey) > 0;
            }
            /// <summary>根据PK_DBField删除DBField信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_FIELD_REF_TABLE删除DBField信息</summary>
            ///<param name="TableIdx">表索引</param>
            public async Task<bool> DelTable(Guid TableIdx)
            {
                return dbAccess.DelTable(TableIdx) > 0;
            }
        }
        #endregion
        #region "应用表索引信息基础控制类声明"
        /// <summary>应用表索引 控制类</summary>
        /// <seealso cref="Von.Web.Models.DBIndexInfo"/>
        public class DBIndexTask
        {
            protected DBIndexAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public DBIndexTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<DBIndexAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, DBIndexInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.TableIdx = reader.GetGuid(1);  //表结构索引
                info.IndexName = reader.GetString(2);  //索引标题
                info.IndexCode = reader.GetString(3);  //索引名称
                info.FieldSet = reader.GetString(4);  //索引字段集合
            }
            /// <summary>检验DBIndex信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : DBIndexInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_DBIndex 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByDBIndex<T>(Guid ID) where T : DBIndexInfo, new()
            {
                IDataReader reader = dbAccess.GetByDBIndex(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 应用表索引 信息</summary>
            public async Task<List<T>> List<T>() where T : DBIndexInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_INDEX_REF_TABLE 提取信息</summary>
            public async Task<List<T>> ListByINDEX_REF_TABLE<T>(Guid TableIdx) where T : DBIndexInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByINDEX_REF_TABLE(TableIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加DBIndex信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : DBIndexInfo, new()
            {
                return dbAccess.Add(info.ID, info.TableIdx, info.IndexName, info.IndexCode, info.FieldSet) > 0;
            }
            /// <summary>修改DBIndex信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : DBIndexInfo, new()
            {
                return dbAccess.Edit(info.ID, info.TableIdx, info.IndexName, info.IndexCode, info.FieldSet) > 0;
            }
            /// <summary>根据PK_DBIndex删除DBIndex信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_INDEX_REF_TABLE删除DBIndex信息</summary>
            ///<param name="TableIdx">表结构索引</param>
            public async Task<bool> DelTable(Guid TableIdx)
            {
                return dbAccess.DelTable(TableIdx) > 0;
            }
        }
        #endregion
        #region "表结构外键信息基础控制类声明"
        /// <summary>表结构外键 控制类</summary>
        /// <seealso cref="Von.Web.Models.DBLinkInfo"/>
        public class DBLinkTask
        {
            protected DBLinkAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public DBLinkTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<DBLinkAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, DBLinkInfo info)
            {
                info.ID = reader.GetInt32(0);  //序号
                info.ForeignKeyName = reader.GetString(1);  //外键标题
                info.ForeignKeyCode = reader.GetString(2);  //外键名称
                info.ParentFieldIdx = reader.GetGuid(3);  //父表字段索引
                info.ChildFieldIdx = reader.GetGuid(4);  //子表字段索引
            }
            /// <summary>检验DBLink信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : DBLinkInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_DBLink 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByDBLink<T>(int ID) where T : DBLinkInfo, new()
            {
                IDataReader reader = dbAccess.GetByDBLink(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 表结构外键 信息</summary>
            public async Task<List<T>> List<T>() where T : DBLinkInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_PARENT_REF_FIELD 提取信息</summary>
            public async Task<List<T>> ListByPARENT_REF_FIELD<T>(Guid ParentFieldIdx) where T : DBLinkInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByPARENT_REF_FIELD(ParentFieldIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_CHILD_REF_FIELD 提取信息</summary>
            public async Task<List<T>> ListByCHILD_REF_FIELD<T>(Guid ChildFieldIdx) where T : DBLinkInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByCHILD_REF_FIELD(ChildFieldIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加DBLink信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : DBLinkInfo, new()
            {
                info.ID = dbAccess.Add(info.ForeignKeyName, info.ForeignKeyCode, info.ParentFieldIdx, info.ChildFieldIdx);
                return info.ID > 0;
            }
            /// <summary>修改DBLink信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : DBLinkInfo, new()
            {
                return dbAccess.Edit(info.ID, info.ForeignKeyName, info.ForeignKeyCode, info.ParentFieldIdx, info.ChildFieldIdx) > 0;
            }
            /// <summary>根据PK_DBLink删除DBLink信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_PARENT_REF_FIELD删除DBLink信息</summary>
            ///<param name="ParentFieldIdx">父表字段索引</param>
            public async Task<bool> DelByField(Guid ChildFieldIdx, Guid ParentFieldIdx)
            {
                return dbAccess.DelByField(ChildFieldIdx, ParentFieldIdx) > 0;
            }
            /// <summary>根据FK_CHILD_REF_FIELD删除DBLink信息</summary>
            ///<param name="ChildFieldIdx">子表字段索引</param>
            public async Task<bool> DelChildField(Guid ChildFieldIdx)
            {
                return dbAccess.DelChildField(ChildFieldIdx) > 0;
            }

        }
        #endregion
    }
    namespace Datas
    {
        #region "数据库表字典信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.DBTableInfo"/>
        /// <seealso cref="Von.Web.Datas.DBAccessBase"/>
        public abstract class DBTableAccess : DBAccessBase
        {
            #region "DBTable Abstract Methods"
            /// <summary>根据主键 PK_DataDictionary 提取信息</summary>
            public abstract IDataReader GetByDataDictionary(Guid ID);
            /// <summary>根据主键 数据库表字典 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据索引 Idx_DataDictionary 提取信息</summary>
            public abstract IDataReader ListByIdx_DataDictionary(bool SupportOrder);
            /// <summary>根据外键 FK_TA_REF_APPLICATION 提取信息</summary>
            public abstract IDataReader ListByApp(Guid ID);
            /// <summary>添加DBTable信息</summary>
            public abstract int Add(Guid ID, string TableCode, string TableName, Guid AppIdx, bool SupportHistory, bool SupportFlow, bool SupportOrder, bool SupportTree, bool SupportTask, bool SupportCRC);
            /// <summary>修改DBTable信息</summary>
            public abstract int Edit(Guid ID, string TableCode, string TableName, Guid AppIdx, bool SupportHistory, bool SupportFlow, bool SupportOrder, bool SupportTree, bool SupportTask, bool SupportCRC);
            /// <summary>根据PK_DataDictionary删除DBTable信息</summary>
            public abstract int Del(Guid ID);
            /// <summary>根据FK_TA_REF_APPLICATION删除DBTable信息</summary>
            public abstract int DelID(Guid ID);
            #endregion
        }
        #endregion
        #region "数据库表字段字典信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.DBFieldInfo"/>
        /// <seealso cref="Von.Web.Operators.DBFieldCtrl"/>
        public abstract class DBFieldAccess : DBAccessBase
        {
            #region "DBField Abstract Methods"
            /// <summary>根据主键 PK_DBField 提取信息</summary>
            public abstract IDataReader GetByDBField(Guid ID);
            /// <summary>根据主键 数据库表字段字典 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据外键 TABLE 提取模型列表</summary>
            public abstract IDataReader ListModelByTable(Guid TableIdx);
            /// <summary>根据外键 FK_FIELD_REF_TABLE 提取信息</summary>
            public abstract IDataReader ListByTable(Guid TableIdx);
            /// <summary>添加DBField信息</summary>
            public abstract int Add(Guid ID, Guid TableIdx, string FieldName, string FieldCode, string FieldType, bool IsPrimaryKey);
            /// <summary>修改DBField信息</summary>
            public abstract int Edit(Guid ID, Guid TableIdx, string FieldName, string FieldCode, string FieldType, bool IsPrimaryKey);
            /// <summary>根据PK_DBField删除DBField信息</summary>
            public abstract int Del(Guid ID);
            /// <summary>根据FK_FIELD_REF_TABLE删除DBField信息</summary>
            public abstract int DelTable(Guid TableIdx);
            #endregion
        }
        #endregion
        #region "应用表索引信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.DBIndexInfo"/>
        /// <seealso cref="Von.Web.Operators.DBIndexCtrl"/>
        public abstract class DBIndexAccess : DBAccessBase
        {
            #region "DBIndex Abstract Methods"
            /// <summary>根据主键 PK_DBIndex 提取信息</summary>
            public abstract IDataReader GetByDBIndex(Guid ID);
            /// <summary>根据主键 应用表索引 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据外键 FK_INDEX_REF_TABLE 提取信息</summary>
            public abstract IDataReader ListByINDEX_REF_TABLE(Guid TableIdx);
            /// <summary>添加DBIndex信息</summary>
            public abstract int Add(Guid ID, Guid TableIdx, string IndexName, string IndexCode, string FieldSet);
            /// <summary>修改DBIndex信息</summary>
            public abstract int Edit(Guid ID, Guid TableIdx, string IndexName, string IndexCode, string FieldSet);
            /// <summary>根据PK_DBIndex删除DBIndex信息</summary>
            public abstract int Del(Guid ID);
            /// <summary>根据FK_INDEX_REF_TABLE删除DBIndex信息</summary>
            public abstract int DelTable(Guid TableIdx);
            #endregion
        }
        #endregion
        #region "表结构外键信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.DBLinkInfo"/>
        /// <seealso cref="Von.Web.Operators.DBLinkCtrl"/>
        public abstract class DBLinkAccess : DBAccessBase
        {
            #region "DBLink Abstract Methods"
            /// <summary>根据主键 PK_DBLink 提取信息</summary>
            public abstract IDataReader GetByDBLink(int ID);
            /// <summary>根据主键 表结构外键 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据外键 FK_PARENT_REF_FIELD 提取信息</summary>
            public abstract IDataReader ListByPARENT_REF_FIELD(Guid ParentFieldIdx);
            /// <summary>根据外键 FK_CHILD_REF_FIELD 提取信息</summary>
            public abstract IDataReader ListByCHILD_REF_FIELD(Guid ChildFieldIdx);
            /// <summary>添加DBLink信息</summary>
            public abstract int Add(string ForeignKeyName, string ForeignKeyCode, Guid ParentFieldIdx, Guid ChildFieldIdx);
            /// <summary>修改DBLink信息</summary>
            public abstract int Edit(int ID, string ForeignKeyName, string ForeignKeyCode, Guid ParentFieldIdx, Guid ChildFieldIdx);
            /// <summary>根据PK_DBLink删除DBLink信息</summary>
            public abstract int Del(int ID);
            /// <summary>根据FK_PARENT_REF_FIELD删除DBLink信息</summary>
            public abstract int DelByField(Guid ChildFieldIdx, Guid ParentFieldIdx);
            /// <summary>根据FK_CHILD_REF_FIELD删除DBLink信息</summary>
            public abstract int DelChildField(Guid ChildFieldIdx);
            #endregion
        }
        #endregion
    }
}
#endregion
#region 成员认证结构
namespace Von.Web
{
    namespace Structs
    {
        public enum IIdentity_Sys_Flag { IS_Host = 200, IS_Admin = 100, IS_Manage = 50, IS_User = 1, IS_Guest = 0 }
        #region 系统登录人员信息
        /// <summary>系统登录人员信息 信息类</summary>
        public class IdentityUserInfo : IIdentity
        {
            //
            // 摘要:
            //     Gets the name of this claims identity.
            //
            // 返回结果:
            //     The name or null.
            public string Name { get { return DisplayName; } }
            //
            // 摘要:
            //     Gets the type of authentication used.
            //
            // 返回结果:
            //     The type of authentication used to identify the user.
            public string AuthenticationType { get { return "VonPortal"; } }
            //
            // 摘要:
            //     Gets a value that indicates whether the user has been authenticated.
            //
            // 返回结果:
            //     true if the user was authenticated; otherwise, false.
            public bool IsAuthenticated { get { return true; } }
            public string this[string name]
            {
                get {
                    if (name.Equals("LoginName", StringComparison.OrdinalIgnoreCase)) return LoginName;
                    else if (name.Equals("Email", StringComparison.OrdinalIgnoreCase)) return Email;
                    else if (name.Equals("PhoneNumber", StringComparison.OrdinalIgnoreCase)) return PhoneNumber;
                    else if (name.Equals("DisplayName", StringComparison.OrdinalIgnoreCase)) return DisplayName;
                    else if (name.Equals("DefaultPage", StringComparison.OrdinalIgnoreCase)) return DefaultPage;
                    else return GetSubsidiary(name).Result;
                }
            }
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "系统登录人员信息")]
            public Guid ID { get; set; }
            /// <summary>登录名</summary>
            [Required]
            [LocalDisplay("登录名", "系统登录人员信息")]
            public string LoginName { get; set; }
            /// <summary>Email</summary>
            [Required]
            [LocalDisplay("Email", "系统登录人员信息")]
            public string Email { get; set; }
            /// <summary>Email确认状态</summary>
            [LocalDisplay("Email确认状态", "系统登录人员信息")]
            public bool EmailConfirmed { get; set; }
            /// <summary>手机号</summary>
            [Required]
            [LocalDisplay("手机号", "系统登录人员信息")]
            public string PhoneNumber { get; set; }
            /// <summary>手机确认状态</summary>
            [LocalDisplay("手机确认状态", "系统登录人员信息")]
            public bool PhoneNumberConfirmed { get; set; }
            /// <summary>密码</summary>
            [LocalDisplay("密码", "系统登录人员信息")]
            public string PasswordHash { get; set; }
            /// <summary>解锁Token</summary>
            [LocalDisplay("解锁Token", "系统登录人员信息")]
            public string SecurityStamp { get; set; }
            /// <summary>锁定状态</summary>
            [LocalDisplay("锁定状态", "系统登录人员信息")]
            public bool LockoutEnabled { get; set; }
            /// <summary>自动解锁时间</summary>
            [LocalDisplay("自动解锁时间", "系统登录人员信息")]
            [JsonConverter(typeof(VonJsonDateConverer))]
            public DateTime LockoutEnd { get; set; }
            /// <summary>显示姓名</summary>
            [LocalDisplay("显示姓名", "系统登录人员信息")]
            public string DisplayName { get; set; }
            /// <summary>登录失败次数</summary>
            [LocalDisplay("登录失败次数", "系统登录人员信息")]
            public int AccessFailedCount { get; set; }
            /// <summary>状态</summary>
            [Required]
            [LocalDisplay("状态", "系统登录人员信息")]
            public string Status { get; set; }
            /// <summary>关联序号0</summary>
            [Required]
            [LocalDisplay("系统标识", "系统登录人员信息")]
            public IIdentity_Sys_Flag SysFlag { get; set; }
            /// <summary>关联序号0</summary>
            [Required]
            [LocalDisplay("系统标识", "默认页面")]
            public string DefaultPage { get; set; }
            #endregion
            #region "Subsidiary"
            private List<SubsidiaryInfo> _Subsidiaries = null;
            public async Task<string> GetSubsidiary(string key)
            {
                SubsidiaryInfo info = (await GetSubsidiaries()).FirstOrDefault(s => s.SubName.Equals(key, StringComparison.OrdinalIgnoreCase));
                if (info == null) return "";
                return info.SubValue;
            }
            public async Task SetSubsidiary(string key, string value,DbTransaction trans=null)
            {
                SubsidiaryInfo info = (await GetSubsidiaries()).FirstOrDefault(s => s.SubName.Equals(key, StringComparison.OrdinalIgnoreCase));
                if (info == null)
                {
                    SubsidiaryTask task = new SubsidiaryTask(trans);
                    info = new SubsidiaryInfo(0, ID, key, value);
                    await task.Add<SubsidiaryInfo>(info);
                    _Subsidiaries.Add(info);
                }
                else
                {
                    if (info.SubValue != value)
                    {
                        SubsidiaryTask task = new SubsidiaryTask(trans);
                        info.SubValue = value;
                        await task.Edit<SubsidiaryInfo>(info);
                    }
                }
            }
            public async Task<List<SubsidiaryInfo>> GetSubsidiaries()
            {
                if (_Subsidiaries == null)
                {
                    SubsidiaryTask task = new SubsidiaryTask();
                    _Subsidiaries = await task.ListBySUBSIDIARY_REF_IDENTITY<SubsidiaryInfo>(ID);
                }
                return _Subsidiaries;
            }
            #endregion
        }
        #endregion
        #region 人员附属信息
        /// <summary>人员附属信息 信息类</summary>
        public class SubsidiaryInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public SubsidiaryInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="IdentityIdx">人员序号</param>
            /// <param name="SubName">项目名称</param>
            /// <param name="SubValue">项目内容</param>
            public SubsidiaryInfo(int ID, Guid IdentityIdx, string SubName, string SubValue)
            {
                this.ID = ID;
                this.IdentityIdx = IdentityIdx;
                this.SubName = SubName;
                this.SubValue = SubValue;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "人员附属信息")]
            public int ID { get; set; }
            /// <summary>人员序号</summary>
            [Required]
            [LocalDisplay("人员序号", "人员附属信息")]
            public Guid IdentityIdx { get; set; }
            /// <summary>项目名称</summary>
            [Required]
            [LocalDisplay("项目名称", "人员附属信息")]
            public string SubName { get; set; }
            /// <summary>项目内容</summary>
            [LocalDisplay("项目内容", "人员附属信息")]
            public string SubValue { get; set; }
            #endregion
        }
        #endregion
        #region 系统角色信息
        /// <summary>系统角色信息 信息类</summary>
        public class IdentityRoleInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public IdentityRoleInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="RoleName">角色名称</param>
            /// <param name="Note">角色描述</param>
            /// <param name="RoleGroup">角色组名称</param>
            public IdentityRoleInfo(string RoleName, string Note, string RoleGroup)
            {
                this.RoleName = RoleName;
                this.Note = Note;
                this.RoleGroup = RoleGroup;
            }
            #endregion
            #region "Public Properties"
            /// <summary>角色名称</summary>
            [Required]
            [LocalDisplay("角色名称", "系统角色信息")]
            public string RoleName { get; set; }
            /// <summary>角色描述</summary>
            [LocalDisplay("角色描述", "系统角色信息")]
            public string Note { get; set; }
            /// <summary>角色组名称</summary>
            [LocalDisplay("角色组名称", "系统角色信息")]
            public string RoleGroup { get; set; }
            #endregion
        }
        #endregion
        #region 人员角色关联
        /// <summary>人员角色关联 信息类</summary>
        public class UserRoleInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public UserRoleInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="UserIdx">人员序号</param>
            /// <param name="RoleName">角色名称</param>
            public UserRoleInfo(int ID, Guid UserIdx, string RoleName)
            {
                this.ID = ID;
                this.UserIdx = UserIdx;
                this.RoleName = RoleName;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "人员角色关联")]
            public int ID { get; set; }
            /// <summary>人员序号</summary>
            [Required]
            [LocalDisplay("人员序号", "人员角色关联")]
            public Guid UserIdx { get; set; }
            /// <summary>角色名称</summary>
            [Required]
            [LocalDisplay("角色名称", "人员角色关联")]
            public string RoleName { get; set; }
            #endregion
        }
        #endregion
        #region 权限控制
        /// <summary>权限控制 信息类</summary>
        public class RightInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public RightInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="RoleName">角色名称</param>
            /// <param name="DestIdx">控制目标序号</param>
            /// <param name="Kind">控制类型</param>
            public RightInfo(int ID, string RoleName, Guid DestIdx, int Kind)
            {
                this.ID = ID;
                this.RoleName = RoleName;
                this.DestIdx = DestIdx;
                this.Kind = Kind;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "权限控制")]
            public int ID { get; set; }
            /// <summary>角色名称</summary>
            [Required]
            [LocalDisplay("角色名称", "权限控制")]
            public string RoleName { get; set; }
            /// <summary>控制目标序号</summary>
            [Required]
            [LocalDisplay("控制目标序号", "权限控制")]
            public Guid DestIdx { get; set; }
            /// <summary>控制类型</summary>
            [LocalDisplay("控制类型", "权限控制")]
            public int Kind { get; set; }
            #endregion
        }
        #endregion
    }
    namespace Models
    {
        #region 成员认证界面状态信息基类
        public class ViewModelBase
        {
            public string StatusMessage { get; set; }
        }
        /// <summary>角色功能权限视图类</summary>
        public class RoleActionRightViewModel
        {
            public Guid ActionID { get; set; }
            public string ActionName { get; set; }
            public int Kind { get; set; }
            public bool Checked { get; set; }
        }
        /// <summary>角色模块权限视图类</summary>
        public class RoleApplicationRightViewModel
        {
            public Guid AppID { get; set; }
            public string AppName { get; set; }
            public string ModuleName { get; set; }
            public List<RoleActionRightViewModel> Actions { get; protected set; }
            public RoleApplicationRightViewModel()
            {
                Actions = new List<RoleActionRightViewModel>();
            }
        }
        /// <summary>角色权限视图类</summary>
        public class RoleRightViewModel
        {
            public string RoleName { get; set; }
            public List<RoleApplicationRightViewModel> AppRights { get; protected set; }
            public RoleRightViewModel()
            {
                AppRights = new List<RoleApplicationRightViewModel>();
            }
            public List<MenuViewModel> Menus { get; set; }
        }
        /// <summary>菜单视图类</summary>
        public class MenuViewModel : MenuInfo
        {
            public string state
            {
                get
                {
                    if (children == null || children.Count == 0) return "open";
                    else return "closed";
                }
            }
            public string text { get { return MenuName; }set { MenuName = value; } }
            [JsonProperty("checked")]
            public bool Checked { get; set; }
            public List<MenuViewModel> children { get; set; }
        }
        #endregion
        #region 系统登录界面录入信息类
        /// <summary>系统登录界面录入信息类</summary>
        public class LoginViewModel : ViewModelBase
        {
            #region "Public Properties"
            /// <summary>登录名</summary>
            [LocalDisplay("登录名", "登录视图")]
            public string LoginName { get; set; }
            /// <summary>密码</summary>
            [LocalDisplay("密码", "登录视图")]
            public string Password { get; set; }
            [LocalDisplay("记住密码?", "登录视图")]
            public bool RememberMe { get; set; }
            #endregion
        }
        #endregion
        #region 系统注册页面录入信息类
        /// <summary>系统注册页面录入信息类</summary>
        public class RegisterViewModel : ViewModelBase
        {
            #region "Public Properties"
            /// <summary>登录名</summary>
            [LocalDisplay("登录名", "系统注册人员信息")]
            public string UserName { get; set; }
            /// <summary>Email</summary>
            [LocalDisplay("Email", "系统注册人员信息")]
            public string Email { get; set; }
            /// <summary>手机号</summary>
            [LocalDisplay("手机号", "系统注册人员信息")]
            public string PhoneNumber { get; set; }
            /// <summary>密码</summary>
            [LocalDisplay("密码", "系统注册人员信息")]
            public string InputPassword { get; set; }
            /// <summary>密码</summary>
            [LocalDisplay("密码", "系统注册人员信息")]
            public string ConfirmPassword { get; set; }
            /// <summary>显示姓名</summary>
            [LocalDisplay("显示姓名", "系统注册人员信息")]
            public string DisplayName { get; set; }
            /// <summary>性别</summary>
            [LocalDisplay("性别", "系统注册人员信息")]
            public string Gender { get; set; }
            /// <summary>出生日期</summary>
            [LocalDisplay("出生日期", "系统注册人员信息")]
            [JsonConverter(typeof(VonJsonDateConverer))]
            public DateTime Birthday { get; set; }
            /// <summary>所属部门</summary>
            [LocalDisplay("所属部门", "系统注册人员信息")]
            public int Department { get; set; }
            /// <summary>关联序号0</summary>
            [Required]
            [LocalDisplay("系统标识", "系统登录人员信息")]
            public IIdentity_Sys_Flag SysFlag { get; set; }
            #endregion
        }
        #endregion
        #region 忘记密码找回界面录入信息类
        public class ForgotPasswordViewModel : ViewModelBase
        {
            [LocalDisplay("找回方式", "找回密码视图")]
            public bool FromEmail { get; set; }
            [LocalDisplay("用户信息", "找回密码视图")]
            public string LoginValue { get; set; }
            [LocalDisplay("发送值", "找回密码视图")]
            public string SendValue { get; set; }
            [LocalDisplay("返回值", "找回密码视图")]
            public string RedeemValue { get; set; }
        }
        #endregion
        #region 系统登录界面录入信息类
        /// <summary>系统登录界面录入信息类</summary>
        public class ChangePasswordViewModel : ViewModelBase
        {
            [Required]
            [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
            [DataType(DataType.Password)]
            [Display(Name = "New password")]
            public string NewPassword { get; set; }

            [DataType(DataType.Password)]
            [Display(Name = "Confirm new password")]
            [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
            public string ConfirmPassword { get; set; }

        }
        #endregion
        #region 角色权限视图类
        /// <summary>角色权限视图类</summary>
        public class RightViewModel : IdentityRoleInfo
        {
            /// <summary>菜单内容</summary>
            [LocalDisplay("用户角色", "是否拥有")]
            public bool Checked { get; set; }
        }
        #endregion
        #region 树形结构数据
        /// <summary>树形结构数据</summary>
        public class TreeViewModel<TKey>
        {
            /// <summary>节点的 id，它对于加载远程数据很重要</summary>
            public TKey id { get; set; }
            /// <summary>要显示的节点文本</summary>
            public string text { get; set; }
            /// <summary>，'open' 或 'closed'，默认是 'open'。当设置为 'closed' 时，该节点有子节点，并且将从远程站点加载它们</summary>
            public string state { get; set; }
            /// <summary>指示节点是否被选中</summary>
            public bool Checked { get; set; }
            /// <summary>给一个节点添加的自定义属性</summary>
            public string attributes { get; set; }
            public List<TreeViewModel<TKey>> children { get; set; }
        }
        #endregion
    }
    namespace Tasks
    {
        #region 系统登录人员信息
        /// <summary>系统登录人员信息 控制类</summary>
        /// <seealso cref="Von.Web.Models.UserInfo"/>
        public class IdentityUserTask
        {
            protected IdentityUserAccess dbAccess = null;
            protected SubsidiaryAccess subsidiaryAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public IdentityUserTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<IdentityUserAccess>(DBTrans);
                subsidiaryAccess = Statement.App.GetAccess<SubsidiaryAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, IdentityUserInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.LoginName = reader.GetString(1);  //登录名
                info.Email = reader.GetString(2);  //Email
                info.EmailConfirmed = reader.GetBoolean(3);  //Email确认状态
                info.PhoneNumber = reader.GetString(4);  //手机号
                info.PhoneNumberConfirmed = reader.GetBoolean(5);  //手机确认状态
                info.PasswordHash = reader.GetString(6);  //密码
                info.SecurityStamp = reader.GetString(7);  //解锁Token
                info.LockoutEnabled = reader.GetBoolean(8);  //锁定状态
                info.LockoutEnd = reader.GetDateTime(9); ;  //自动解锁时间
                info.DisplayName = reader.GetString(10);  //显示姓名
                info.AccessFailedCount = reader.GetInt32(11);  //登录失败次数
                info.Status = reader.GetString(12);  //状态
                info.SysFlag = (IIdentity_Sys_Flag)reader.GetInt32(13);  //系统标识
            }
            /// <summary>检验 Password 信息</summary>
            public async Task<ExecuteResult> CheckPassword(string Password)
            {
                Regex regex;
                if (string.IsNullOrEmpty(Password)) return ExecuteResult.Failed(Statement.App.ResxName, "参数不正确，无法执行");
                //密码正则表达式对象
                regex = Statement.App.AppSetting["PasswordStrength"] == null
                    ? new Regex(@"(?=.*[0-9])(?=.*[a-zA-Z])(?=([\x21-\x7e]+)[^a-zA-Z0-9]).{8,30}", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace)
                    : new Regex(Statement.App.AppSetting["PasswordStrength"].ToString());
               
                if (!regex.IsMatch(Password)) return ExecuteResult.Failed("1002", Statement.App.AppSetting["PasswordRequirement"].ToString());
                return ExecuteResult.Success(true);
            }
            /// <summary>检验 Email 信息</summary>
            public async Task<ExecuteResult> CheckEmail(string Email)
            {
                Regex regex;
                if (string.IsNullOrEmpty(Email)) return ExecuteResult.Failed(Statement.App.ResxName, "参数不正确，无法执行");
                //密码正则表达式对象
                regex = new Regex(@"([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+");
                if (!regex.IsMatch(Email)) return ExecuteResult.Failed("1002", "输入的是有效的邮件地址格式。");
                return ExecuteResult.Success(true);
            }
            /// <summary>检验 Mobile 信息</summary>
            public async Task<ExecuteResult> CheckMobile(string Mobile)
            {
                Regex regex;
                if (string.IsNullOrEmpty(Mobile)) return ExecuteResult.Failed(Statement.App.ResxName, "参数不正确，无法执行");
                //密码正则表达式对象
                regex = new Regex(@"(^(\d{2,4}[-_－—]?)?\d{3,8}([-_－—]?\d{3,8})?([-_－—]?\d{1,7})?$)|(^0?1[35]\d{9}$)");
                if (!regex.IsMatch(Mobile)) return ExecuteResult.Failed("1002", "输入的是有效的邮件地址格式。");
                return ExecuteResult.Success(true);
            }
            /// <summary>检验Identity信息</summary>
            public async Task<ExecuteResult> Check(IdentityUserInfo info, string aPassword)
            {
                /// <summary>根据索引 IDX_LoginName 提取信息</summary>
                if (string.IsNullOrEmpty(info.LoginName)) return ExecuteResult.Failed("1001", "登录名");
                /// <summary>根据索引 IDX_Email 提取信息</summary>
                if (string.IsNullOrEmpty(info.Email)) return ExecuteResult.Failed("1001", "Email");
                /// <summary>根据索引 IDX_PhongNumber 提取信息</summary>
                if (string.IsNullOrEmpty(info.PhoneNumber)) return ExecuteResult.Failed("1001", "手机号");
                ExecuteResult result = await CheckPassword(aPassword); if (!result.Successed) return result;
                result = await CheckEmail(info.Email); if (!result.Successed) return result;
                result = await CheckMobile(info.PhoneNumber); if (!result.Successed) return result;
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Identity 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public IdentityUserInfo GetByIdentitySync(Guid ID)
            {
                IDataReader reader = dbAccess.GetByIdentity(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                IdentityUserInfo info = new IdentityUserInfo();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>
            /// 根据主键 PK_Identity 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<IdentityUserInfo> GetByIdentity(Guid ID)
            {
                IDataReader reader = dbAccess.GetByIdentity(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                IdentityUserInfo info = new IdentityUserInfo();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 系统登录人员信息 信息</summary>
            public async Task<List<T>> List<T>() where T: IdentityUserInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_Link0 提取信息</summary>
            /// <param name="Status">状态</param>
            /// <param name="Link0">关联序号0</param>
            public async Task<List<T>> ListBySubsidiary<T>(string Key, string Value) where T: IdentityUserInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListBySubsidiary(Key, Value);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_LoginName 提取信息</summary>
            /// <param name="LoginName">登录名</param>
            public async Task<T> GetByLoginName<T>(string LoginName)where T: IdentityUserInfo, new()
            {
                IDataReader reader = dbAccess.GetByLoginName(LoginName);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            } 
            /// <summary>根据索引 IDX_Email 提取信息</summary>
            /// <param name="Email">Email</param>
            public async Task<T> GetByEmail<T>(string Email)where T: IdentityUserInfo, new()
            {
                IDataReader reader = dbAccess.GetByEmail(Email);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>根据索引 IDX_PhongNumber 提取信息</summary>
            /// <param name="PhoneNumber">手机号</param>
            public async Task<T> GetByPhoneNumber<T>(string PhoneNumber)where T: IdentityUserInfo, new()
            {
                IDataReader reader = dbAccess.GetByPhoneNumber(PhoneNumber);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>修改登录邮箱</summary>
            ///<param name="ID">人员序号</param>
            ///<param name="aEmail">新邮箱</param>
            public async Task<bool> ChangeEmail(Guid ID, string Email)
            {
                return dbAccess.ChangeProperty(ID, "Email", Email) > 0;
            }
            /// <summary>修改登录联系电话</summary>
            ///<param name="ID">人员序号</param>
            ///<param name="aPhoneNumber">新联系电话</param>
            public async Task<bool> ChangeMobile(Guid ID, string PhoneNumber)
            {
                return dbAccess.ChangeProperty(ID, "PhoneNumber", PhoneNumber) > 0;
            }
            /// <summary>修改登录联系电话</summary>
            ///<param name="ID">人员序号</param>
            ///<param name="aPhoneNumber">新联系电话</param>
            public async Task<bool> ChangeDisplayName(Guid ID, string DisplayName)
            {
                return dbAccess.ChangeProperty(ID, "DisplayName", DisplayName) > 0;
            }
            /// <summary>修改登录口令</summary>
            ///<param name="ID">人员序号</param>
            ///<param name="aPassword">新密码</param>
            public async Task<bool> ChangePassword(Guid ID, string aPassword)
            {
                IdentityUserInfo info = await GetByIdentity(ID);
                if (info == null) return false;
                string PasswordHash = HashPassword(info, aPassword);
                return dbAccess.ChangeProperty(ID, "PasswordHash", PasswordHash) > 0;
            }
            public async Task<bool> LoginFaild(Guid ID)
            {
                IdentityUserInfo info = await GetByIdentity(ID);
                if (info == null) return false;
                KeyObjectCollection values = new KeyObjectCollection();
                info.AccessFailedCount += 1;
                if (info.AccessFailedCount > 5)
                {
                    info.LockoutEnabled = true;
                    info.LockoutEnd = System.DateTime.Now.AddMinutes(20);
                }
                values.Add(new KeyObject("AccessFailedCount", info.AccessFailedCount));
                values.Add(new KeyObject("LockoutEnabled", info.LockoutEnabled));
                values.Add(new KeyObject("LockoutEnd", info.LockoutEnd));
                return dbAccess.Update(ID, values) > 0;
            }
            public async Task<byte[]> GetUserIcon(Guid ID)
            {
                return dbAccess.GetUserIcon(ID);
            }
            public async Task<bool> SetUserIcon(Guid ID, Stream file)
            {
                return dbAccess.SetUserIcon(ID, file) > 0;
            }
            public async Task<bool> LoginSuccessed(Guid ID)
            {
                KeyObjectCollection values = new KeyObjectCollection();
                values.Add(new KeyObject("AccessFailedCount", 0));
                values.Add(new KeyObject("LockoutEnabled", false));
                values.Add(new KeyObject("LockoutEnd", Consts.MinDBDate));
                return dbAccess.Update(ID, values) > 0;
            }
            public async Task<bool> Update(Guid ID, KeyObjectCollection values)
            {
                if (values.Count > 0)
                    return dbAccess.Update(ID, values) > 0;
                return true;
            }
            /// <summary>添加Identity信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(IdentityUserInfo info, string password)
            {
                info.ID = Guid.NewGuid();
                info.EmailConfirmed = false;
                info.PhoneNumberConfirmed = false;
                info.SecurityStamp = Functions.RandomStr(64);
                info.LockoutEnabled = false;
                info.LockoutEnd = Consts.MinDBDate;
                info.AccessFailedCount = 0;
                info.Status = "注册";
                info.PasswordHash = HashPassword(info, password);
                bool result = dbAccess.Add(info.ID, info.LoginName, info.Email, info.EmailConfirmed, info.PhoneNumber, info.PhoneNumberConfirmed, info.PasswordHash, info.SecurityStamp, info.LockoutEnabled, info.LockoutEnd, info.DisplayName, info.AccessFailedCount, info.Status, (int)info.SysFlag) > 0;
                if (!result) return false;
                foreach(SubsidiaryInfo sub in await info.GetSubsidiaries())
                {
                    if(subsidiaryAccess.Add(info.ID, sub.SubName, sub.SubValue) == 0) return false;
                }
                return true;
            }
            public async Task<bool> Edit(IdentityUserInfo info)
            {
                bool result = dbAccess.Edit(info.ID, info.LoginName, info.Email, info.EmailConfirmed, info.PhoneNumber, info.PhoneNumberConfirmed, info.DisplayName, (int)info.SysFlag) > 0;
                if (!result) return false;
                foreach (SubsidiaryInfo sub in await info.GetSubsidiaries())
                {
                    if (sub.ID == 0) sub.ID = subsidiaryAccess.Add(info.ID, sub.SubName, sub.SubValue);
                    else subsidiaryAccess.Edit(sub.ID, sub.IdentityIdx, sub.SubName, sub.SubValue);
                }
                return true;
            }
            /// <summary>检查信息的重复性</summary>
            public async Task<bool> CheckDoubly(string FieldName, object Value)
            {
                return dbAccess.CheckDoubly(FieldName, Value) == 0;
            }
            /// <summary>根据PK_Identity删除Identity信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            public string HashPassword(IdentityUserInfo id, string password)
            {
                return VonCrypt.Hashto(VonCrypt.HashKind.SHA512, id.ID.ToString() + id.LoginName + id.SecurityStamp + password);
            }
            public async Task<bool> CheckPassword(IdentityUserInfo id, string password)
            {
                string s = HashPassword(id, password);
                return id.PasswordHash == s;
            }
        }
        #endregion
        #region 人员附属信息
        /// <summary>人员附属信息 控制类</summary>
        /// <seealso cref="Von.Web.Models.SubsidiaryInfo"/>
        public class SubsidiaryTask
        {
            protected SubsidiaryAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public SubsidiaryTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<SubsidiaryAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, SubsidiaryInfo info)
            {
                info.ID = reader.GetInt32(0);  //序号
                info.IdentityIdx = reader.GetGuid(1);  //人员序号
                info.SubName = reader.GetString(2);  //项目名称
                info.SubValue = reader.GetString(3);  //项目内容
            }
            /// <summary>检验Subsidiary信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : SubsidiaryInfo, new()
            {
                /// <summary>根据索引 IDX_Subsidiary 提取信息</summary>
                if (info.IdentityIdx == Guid.Empty) return ExecuteResult.Failed("1001", "人员序号");
                /// <summary>根据索引 IDX_Subsidiary 提取信息</summary>
                if (string.IsNullOrEmpty(info.SubName)) return ExecuteResult.Failed("1001", "项目名称");
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Subsidiary 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetBySubsidiary<T>(int ID) where T : SubsidiaryInfo, new()
            {
                IDataReader reader = dbAccess.GetBySubsidiary(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 人员附属信息 信息</summary>
            public async Task<List<T>> List<T>(Guid IdentityIdx) where T : SubsidiaryInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListBySUBSIDIARY_REF_IDENTITY(IdentityIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_Subsidiary 提取信息</summary>
            /// <param name="IdentityIdx">人员序号</param>

            /// <param name="SubName">项目名称</param>
            public async Task<T> GetBySubsidiary<T>(Guid IdentityIdx, string SubName) where T : SubsidiaryInfo, new()
            {
                IDataReader reader = dbAccess.GetBySubsidiary(IdentityIdx, SubName);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }

            /// <summary>根据外键 FK_SUBSIDIARY_REF_IDENTITY 提取信息</summary>
            public async Task<List<T>> ListBySUBSIDIARY_REF_IDENTITY<T>(Guid IdentityIdx) where T : SubsidiaryInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListBySUBSIDIARY_REF_IDENTITY(IdentityIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加Subsidiary信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : SubsidiaryInfo, new()
            {
                info.ID = dbAccess.Add(info.IdentityIdx, info.SubName, info.SubValue);
                return info.ID > 0;
            }
            /// <summary>修改Subsidiary信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : SubsidiaryInfo, new()
            {
                return dbAccess.Edit(info.ID, info.IdentityIdx, info.SubName, info.SubValue) > 0;
            }
            /// <summary>根据PK_Subsidiary删除Subsidiary信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_SUBSIDIARY_REF_IDENTITY删除Subsidiary信息</summary>
            ///<param name="IdentityIdx">人员序号</param>
            public async Task<bool> DelIdentity(Guid IdentityIdx)
            {
                return dbAccess.DelIdentity(IdentityIdx) > 0;
            }
            /// <summary>根据FK_SUBSIDIARY_REF_IDENTITY删除Subsidiary信息</summary>
            ///<param name="IdentityIdx">人员序号</param>
            public async Task<bool> DelIdentity(Guid IdentityIdx, string SubName)
            {
                return dbAccess.DelIdentity(IdentityIdx, SubName) > 0;
            }
        }
        #endregion
        #region 系统角色信息
        /// <summary>系统角色信息 控制类</summary>
        /// <seealso cref="Von.Portal.Models.RoleInfo"/>
        public class IdentityRoleTask
        {
            protected IdentityRoleAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public IdentityRoleTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<IdentityRoleAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, IdentityRoleInfo info)
            {
                info.RoleName = reader.GetString(0);  //角色名称
                info.Note = reader.GetString(1);  //角色描述
                info.RoleGroup = reader.GetString(2);  //角色组名称
            }
            /// <summary>检验Role信息</summary>
            public async Task<ExecuteResult> Check(IdentityRoleInfo info)
            {
                if (string.IsNullOrEmpty(info.RoleName)) return ExecuteResult.Failed("1001", "角色名称");
                if (string.IsNullOrEmpty(info.RoleGroup)) return ExecuteResult.Failed("1001", "角色分组");
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Role 提取信息
            /// </summary>
            /// <param name="RoleName">角色名称</param>
            public async Task<IdentityRoleInfo> GetByRole(string RoleName)
            {
                IDataReader reader = dbAccess.GetByRole(RoleName);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                IdentityRoleInfo info = new IdentityRoleInfo();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 系统角色信息 信息</summary>
            public async Task<List<T>> List<T>() where T : IdentityRoleInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>提取所有 系统角色信息 信息</summary>
            public async Task<string> GetGroupNames()
            {
                string result = "";
                IDataReader reader = dbAccess.GetGroupNames();
                while (reader.Read())
                {
                    result += "," + reader.GetString(0);
                }
                reader.Close();
                if (result.Length > 0) return result.Substring(1);
                return "";
            }
            /// <summary>根据角色分组提取所有 系统角色信息 信息</summary>
            public async Task<List<T>> ListByGroup<T>(string GroupName) where T : IdentityRoleInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByGroup(GroupName);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加Role信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(IdentityRoleInfo info)
            {
                return dbAccess.Add(info.RoleName, info.Note, info.RoleGroup) > 0;
            }
            /// <summary>修改Role信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(IdentityRoleInfo info)
            {
                return dbAccess.Edit(info.RoleName, info.Note, info.RoleGroup) > 0;
            }
            /// <summary>根据PK_Role删除Role信息</summary>
            /// <param name="RoleName">角色名称</param>
            public async Task<bool> Del(string RoleName)
            {
                return dbAccess.Del(RoleName) > 0;
            }
        }
        #endregion
        #region 人员角色关联
        /// <summary>人员角色关联 控制类</summary>
        /// <seealso cref="Von.Portal.Models.UserRoleInfo"/>
        public class UserRoleTask
        {
            protected UserRoleAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public UserRoleTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<UserRoleAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, UserRoleInfo info)
            {
                info.ID = reader.GetInt32(0);  //序号
                info.UserIdx = reader.GetGuid(1);  //人员序号
                info.RoleName = reader.GetString(2);  //角色名称
            }
            /// <summary>检验UserRole信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : UserRoleInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_UserRole 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByUserRole<T>(int ID) where T : UserRoleInfo, new()
            {
                IDataReader reader = dbAccess.GetByUserRole(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 人员角色关联 信息</summary>
            public async Task<List<T>> List<T>() where T : UserRoleInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_User 提取信息</summary>
            /// <param name="UserIdx">人员序号</param>
            public async Task<List<T>> ListByUser<T>(Guid UserIdx) where T : UserRoleInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByUser(UserIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_Role 提取信息</summary>
            /// <param name="RoleName">角色名称</param>
            public async Task<List<T>> ListByRole<T>(string RoleName) where T : UserRoleInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByRole(RoleName);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_IDENTITY_REF_ROLE 提取信息</summary>
            public async Task<List<T>> ListByIDENTITY_REF_ROLE<T>(Guid UserIdx) where T : UserRoleInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByIDENTITY_REF_ROLE(UserIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_ROLE_REF_IDENTITY 提取信息</summary>
            public async Task<List<T>> ListByROLE_REF_IDENTITY<T>(string RoleName) where T : UserRoleInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByROLE_REF_IDENTITY(RoleName);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>保存UserRole信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Save<T>(T info) where T : UserRoleInfo, new()
            {
                if (info.ID == 0) return await Add(info);
                else return await Edit(info);
            }
            /// <summary>添加UserRole信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(UserRoleInfo info)
            {
                info.ID = dbAccess.Add(info.UserIdx, info.RoleName);
                return info.ID > 0;
            }
            /// <summary>修改UserRole信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : UserRoleInfo, new()
            {
                return dbAccess.Edit(info.ID, info.UserIdx, info.RoleName) > 0;
            }
            /// <summary>根据PK_UserRole删除UserRole信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_IDENTITY_REF_ROLE删除UserRole信息</summary>
            ///<param name="UserIdx">人员序号</param>
            public async Task<bool> DelUser(Guid UserIdx)
            {
                return dbAccess.DelUser(UserIdx) >= 0;
            }
            /// <summary>根据FK_ROLE_REF_IDENTITY删除UserRole信息</summary>
            ///<param name="RoleName">角色名称</param>
            public async Task<bool> DelRoleName(string RoleName)
            {
                return dbAccess.DelRoleName(RoleName) > 0;
            }

        }
        #endregion
        #region 权限控制
        /// <summary>权限控制 控制类</summary>
        /// <seealso cref="Von.Portal.Models.RightInfo"/>
        public class RightTask
        {
            protected RightAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public RightTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<RightAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, RightInfo info)
            {
                info.ID = reader.GetInt32(0);  //序号
                info.RoleName = reader.GetString(1);  //角色名称
                info.DestIdx = reader.GetGuid(2);  //控制目标序号
                info.Kind = reader.GetInt32(3);  //控制类型
            }
            /// <summary>检验Right信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : RightInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_TabRole 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByTabRole<T>(int ID) where T : RightInfo, new()
            {
                IDataReader reader = dbAccess.GetByTabRole(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 权限控制 信息</summary>
            public async Task<List<T>> ListByUser<T>(Guid ID, int Kind = 0) where T : RightInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByUser(ID, Kind);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_DestIdx 提取信息</summary>
            /// <param name="DestIdx">控制目标序号</param>
            public async Task<List<T>> ListByDestIdx<T>(Guid DestIdx) where T : RightInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByDestIdx(DestIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_RIGHT_REF_ROLE 提取信息</summary>
            public async Task<List<T>> ListByRIGHT_REF_ROLE<T>(string RoleName) where T : RightInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByRIGHT_REF_ROLE(RoleName);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>保存Right信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Save<T>(T info) where T : RightInfo, new()
            {
                if (info.ID == 0) return await Add(info);
                else return await Edit(info);
            }
            /// <summary>添加Right信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : RightInfo, new()
            {
                info.ID = dbAccess.Add(info.RoleName, info.DestIdx, info.Kind);
                return info.ID > 0;
            }
            /// <summary>修改Right信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : RightInfo, new()
            {
                return dbAccess.Edit(info.ID, info.RoleName, info.DestIdx, info.Kind) > 0;
            }
            /// <summary>根据PK_TabRole删除Right信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_RIGHT_REF_ROLE删除Right信息</summary>
            ///<param name="RoleName">角色名称</param>
            public async Task<bool> DelRoleName(string RoleName)
            {
                return dbAccess.DelRoleName(RoleName) > 0;
            }
        }
        #endregion
    }
    namespace Datas
    {
        #region IdentityUserAccess
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.DBTableInfo"/>
        /// <seealso cref="Von.Web.Datas.DBAccessBase"/>
        public abstract class IdentityUserAccess : DBAccessBase
        {
            #region "DBTable Abstract Methods"
            /// <summary>根据主键 PK_DataDictionary 提取信息</summary>
            public abstract IDataReader GetByIdentity(Guid ID);
            /// <summary>根据主键 数据库表字典 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据附属信息值 提取成员信息</summary>
            public abstract IDataReader ListBySubsidiary(string key, string value);
            /// <summary>根据外键 LoginName 提取信息</summary>
            public abstract IDataReader GetByLoginName(string LoginName);
            /// <summary>根据外键 Email 提取信息</summary>
            public abstract IDataReader GetByEmail(string LoginName);
            /// <summary>根据外键 PhoneNumber 提取信息</summary>
            public abstract IDataReader GetByPhoneNumber(string PhoneNumber);
            /// <summary>提取用户头像</summary>
            /// <param name="ID">序号</param>
            public abstract byte[] GetUserIcon(Guid ID);
            public abstract int SetUserIcon(Guid ID, Stream file);
            /// <summary>检查重复项</summary>
            public abstract int CheckDoubly(string FieldName, object Value);
            /// <summary>添加DBTable信息</summary>
            public abstract int Add(Guid ID, string LoginName, string Email, bool EmailConfirmed, string PhoneNumber, bool PhoneNumberConfirmed, string PasswordHash, string SecurityStamp, bool LockoutEnabled, DateTime LockoutEnd, string DisplayName, int AccessFailedCount, string Status, int SysFlag);
            /// <summary>修改DBTable信息</summary>
            public abstract int Edit(Guid ID, string LoginName, string Email, bool EmailConfirmed, string PhoneNumber, bool PhoneNumberConfirmed, string DisplayName, int SysFlag);
            /// <summary>修改Identity信息</summary>
            /// <param name="ID">序号</param>
            /// <param name="LoginName">登录名</param>
            /// <param name="Email">Email</param>
            /// <param name="EmailConfirmed">Email确认状态</param>
            /// <param name="PhoneNumber">手机号</param>
            /// <param name="PhoneNumberConfirmed">手机确认状态</param>
            /// <param name="PasswordHash">密码</param>
            /// <param name="SecurityStamp">解锁Token</param>
            /// <param name="LockoutEnabled">锁定状态</param>
            /// <param name="LockoutEnd">自动解锁时间</param>
            /// <param name="DisplayName">显示姓名</param>
            /// <param name="AccessFailedCount">登录失败次数</param>
            /// <param name="Status">状态</param>
            public abstract int Update(Guid ID, KeyObjectCollection values);
                /// <summary>修改Identity信息</summary>
            public abstract int ChangeProperty(Guid ID, string FieldName, object Value);
            /// <summary>根据PK_DataDictionary删除DBTable信息</summary>
            public abstract int Del(Guid ID);
            #endregion
        }
        #endregion
        #region SubsidiaryAccess
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.SubsidiaryInfo"/>
        /// <seealso cref="Von.Web.Operators.SubsidiaryCtrl"/>
        public abstract class SubsidiaryAccess : DBAccessBase
        {
            #region "Subsidiary Abstract Methods"
            /// <summary>根据主键 PK_Subsidiary 提取信息</summary>
            public abstract IDataReader GetBySubsidiary(int ID);
            /// <summary>根据主键 人员附属信息 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据索引 IDX_Subsidiary 提取信息</summary>
            public abstract IDataReader GetBySubsidiary(Guid IdentityIdx, string SubName);
            /// <summary>根据外键 FK_SUBSIDIARY_REF_IDENTITY 提取信息</summary>
            public abstract IDataReader ListBySUBSIDIARY_REF_IDENTITY(Guid IdentityIdx);
            /// <summary>添加Subsidiary信息</summary>
            public abstract int Add(Guid IdentityIdx, string SubName, string SubValue);
            /// <summary>修改Subsidiary信息</summary>
            public abstract int Edit(int ID, Guid IdentityIdx, string SubName, string SubValue);
            /// <summary>根据PK_Subsidiary删除Subsidiary信息</summary>
            public abstract int Del(int ID);
            /// <summary>根据FK_SUBSIDIARY_REF_IDENTITY删除Subsidiary信息</summary>
            public abstract int DelIdentity(Guid IdentityIdx);
            /// <summary>根据FK_SUBSIDIARY_REF_IDENTITY删除Subsidiary信息</summary>
            public abstract int DelIdentity(Guid IdentityIdx, string SubName);
            #endregion
        }
        #endregion
        #region IdentityRoleAccess
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Portal.Models.RoleInfo"/>
        /// <seealso cref="Von.Portal.Operators.RoleCtrl"/>
        public abstract class IdentityRoleAccess : DBAccessBase
        {
            #region "Role Abstract Methods"
            /// <summary>根据主键 PK_Role 提取信息</summary>
            public abstract IDataReader GetByRole(string RoleName);
            /// <summary>根据主键 系统角色信息 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>添加Role信息</summary>
            public abstract int Add(string RoleName, string Note, string RoleGroup);
            /// <summary>修改Role信息</summary>
            public abstract int Edit(string RoleName, string Note, string RoleGroup);
            /// <summary>根据PK_Role删除Role信息</summary>
            public abstract int Del(string RoleName);
            /// <summary>根据GroupName获取角色列表</summary>
            public abstract IDataReader ListByGroup(string groupName);
            /// <summary>获取角色分组名称列表</summary>
            public abstract IDataReader GetGroupNames();
            #endregion
        }
        #endregion
        #region UserRoleAccess
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Portal.Models.UserRoleInfo"/>
        /// <seealso cref="Von.Portal.Operators.UserRoleCtrl"/>
        public abstract class UserRoleAccess : DBAccessBase
        {
            #region "UserRole Abstract Methods"
            /// <summary>根据主键 PK_UserRole 提取信息</summary>
            public abstract IDataReader GetByUserRole(int ID);
            /// <summary>根据主键 人员角色关联 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据索引 IDX_User 提取信息</summary>
            public abstract IDataReader ListByUser(Guid UserIdx);
            /// <summary>根据索引 IDX_Role 提取信息</summary>
            public abstract IDataReader ListByRole(string RoleName);
            /// <summary>根据外键 FK_IDENTITY_REF_ROLE 提取信息</summary>
            public abstract IDataReader ListByIDENTITY_REF_ROLE(Guid UserIdx);
            /// <summary>根据外键 FK_ROLE_REF_IDENTITY 提取信息</summary>
            public abstract IDataReader ListByROLE_REF_IDENTITY(string RoleName);
            /// <summary>添加UserRole信息</summary>
            public abstract int Add(Guid UserIdx, string RoleName);
            /// <summary>修改UserRole信息</summary>
            public abstract int Edit(int ID, Guid UserIdx, string RoleName);
            /// <summary>根据PK_UserRole删除UserRole信息</summary>
            public abstract int Del(int ID);
            /// <summary>根据FK_IDENTITY_REF_ROLE删除UserRole信息</summary>
            public abstract int DelUser(Guid UserIdx);
            /// <summary>根据FK_ROLE_REF_IDENTITY删除UserRole信息</summary>
            public abstract int DelRoleName(string RoleName);
            #endregion
        }
        #endregion
        #region RightAccess
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Portal.Models.RightInfo"/>
        /// <seealso cref="Von.Portal.Operators.RightCtrl"/>
        public abstract class RightAccess : DBAccessBase
        {
            #region "Right Abstract Methods"
            /// <summary>根据主键 PK_TabRole 提取信息</summary>
            public abstract IDataReader GetByTabRole(int ID);
            /// <summary>根据主键 权限控制 提取信息</summary>
            public abstract IDataReader ListByUser(Guid ID, int Kind);
            /// <summary>根据索引 IDX_DestIdx 提取信息</summary>
            public abstract IDataReader ListByDestIdx(Guid DestIdx);
            /// <summary>根据外键 FK_RIGHT_REF_ROLE 提取信息</summary>
            public abstract IDataReader ListByRIGHT_REF_ROLE(string RoleName);
            /// <summary>添加Right信息</summary>
            public abstract int Add(string RoleName, Guid DestIdx, int Kind);
            /// <summary>修改Right信息</summary>
            public abstract int Edit(int ID, string RoleName, Guid DestIdx, int Kind);
            /// <summary>根据PK_TabRole删除Right信息</summary>
            public abstract int Del(int ID);
            /// <summary>根据FK_RIGHT_REF_ROLE删除Right信息</summary>
            public abstract int DelRoleName(string RoleName);
            #endregion
        }
        #endregion
    }
}
#endregion
#region 系统工具
namespace Von.Web
{
    /// <summary>
    /// 平台服务
    /// </summary>
    public class AppThread : WebServiceBase
    {
        // 待执行系统日志清除时间，系统默认半年清理一次，每次清理一年前数据
        private DateTime LogLasterTime = (new DateTime(DateTime.Now.Year, 1, 1)).AddMonths(6);
        /// <summary>
        /// 构造函数
        /// </summary>
        public AppThread()
        {
            this.ID = new Guid("{67232758-B82F-4D3A-B895-E2DD24544973}");
            this.ServiceName = "系统服务";
            this.InterKind = ServiceInterKind.秒;
            this.Intervalue = 10;
            this.Necessary = false;
            this.App = Statement.App;
            this.Status = "启用";
            this.Param = "";
        }
        /// <summary>
        /// 服务执行函数
        /// </summary>
        /// <returns></returns>
        public override async Task Run()
        {
            // 清除半年前数据库中系统日志，系统默认半年清理一次，每次清理一年前数据
            if (DateTime.Now > LogLasterTime)
            {
                (new LogTask()).Empty(LogLasterTime.AddYears(-1));
                LogLasterTime = LogLasterTime.AddMonths(6);
            }
            return;
        }
    }
    namespace Models
    {
        /// <summary>
        /// 系统选项模块声明
        /// </summary>
        public class OptionModel : OptionInfo
        {
            public string OptValues { get; set; }
        }
        /// <summary>
        /// Html内容信息模块声明
        /// </summary>
        public class HtmlContentModel : HtmlContentInfo
        {
            public string Summary { get; set; }
            public string Content { get; set; }
        }
        /// <summary>
        /// 文本文档分类视图类声明
        /// </summary>
        public class HtmlCatalogTree : HtmlCatalogInfo
        {
            /// <summary>节点的 id，它对于加载远程数据很重要</summary>
            public int id { get { return this.ID; } }
            /// <summary>要显示的节点文本</summary>
            public string text { get { return this.CatalogName; } }
            /// <summary>，'open' 或 'closed'，默认是 'open'。当设置为 'closed' 时，该节点有子节点，并且将从远程站点加载它们</summary>
            public string state { get { return "open"; } }
            /// <summary>指示节点是否被选中</summary>
            [JsonProperty(PropertyName = "checked")]
            public bool Checked { get; set; }
            /// <summary>给一个节点添加的自定义属性</summary>
            public string attributes { get { return ""; } }
            public List<HtmlCatalogTree> children { get; set; }
        }
        /// <summary>
        /// 信息评论模块显示内容
        /// </summary>
        public enum ECommentStyle { 支持头像, 支持评分, 支持赞成, 支持反对, 支持回复, 支持评论列表 }
        /// <summary>
        /// 信息评论模块
        /// </summary>
        public class CommentPartialModel
        {
            public string Summary { get; set; }
            public string Kind { get; set; }
            public string Linker { get; set; }
            public ECommentStyle[] Style { get; set; }
        }
        /// <summary>
        /// 平台广告信息模块声明
        /// </summary>
        public class SliderModel : SliderInfo
        {
            /// <summary>引用资料</summary>
            [LocalDisplay("引用资料", "主页广告")]
            public string Import { get; set; } = "";
            /// <summary>内容</summary>
            [LocalDisplay("内容", "主页广告")]
            public string Content { get; set; } = "";
        }
        /// <summary>
        /// 大屏扩展信息
        /// </summary>
        public class ScreenModel : ScreenInfo
        {
            /// <summary>私有样式</summary>
            public string Style { get; set; }
        }
        /// <summary>
        /// 大屏组件扩展信息
        /// </summary>
        public class ScreenItemModel : ScreenItemInfo
        {
            public void Import(Dictionary<string, object> data)
            {
                this.ID = (int)data["ID"];  //序号
                this.ItemType = (string)data["ItemType"];  //组件类型
                this.ScreenIdx = (int)data["ScreenIdx"];  //所属大屏
                this.PosX = (int)data["PosX"];  //位置X
                this.PosY = (int)data["PosY"];  //位置Y
                this.Width = (int)data["Width"];  //宽度
                this.Height = (int)data["Height"];  //高度
                this.UpdateUnit = ((string)data["UpdateUnit"])[0];  //更新频率单位
                this.UpdateTime = (int)data["UpdateTime"];  //频率值
                this.DisplayOrder = (int)data["DisplayOrder"];  //显示序号
                this.Style = (string)data["Style"];  //样式
                //this.SampleData = (string)data["SampleData"];  //样例数据
                //this.Setting = JObject.Parse((string)data["Setting"]);  //设置参数
            }
            /// <summary>样式</summary>
            public string Style { get; set; }
            /// <summary>样例数据</summary>
            public string SampleData { get; set; }
            /// <summary>设置参数</summary>
            public JObject Setting { get; set; }
        }
    }
    namespace Apis
    {
        // 主页广告(Von_Slider)
        #region "主页广告接口声明"
        public interface SliderInterface
        {
            #region "Properties"
            /// <summary>序号</summary>
            int ID { get; set; }
            /// <summary>类型</summary>
            string Kind { get; set; }
            /// <summary>名称</summary>
            string Title { get; set; }
            /// <summary>有效期</summary>
            [JsonConverter(typeof(VonJsonDateConverer))]
            DateTime Validate { get; set; }
            /// <summary>链接</summary>
            string Linker { get; set; }
            /// <summary>显示顺序</summary>
            public int DisplayOrder { get; set; }
            #endregion
        }
        #endregion
        // 系统日志(Von_Log)
        #region "系统日志接口声明"
        public interface LogInterface
        {
            #region "Properties"
            /// <summary>时间</summary>
            [JsonConverter(typeof(VonJsonDateConverer))]
            DateTime LogTime { get; set; }
            /// <summary>事件</summary>
            string EventName { get; set; }
            /// <summary>等级</summary>
            int Level { get; set; }
            /// <summary>内容</summary>
            string Content { get; set; }
            /// <summary>操作人</summary>
            string Operator { get; set; }
            #endregion
        }
        #endregion
        // 大屏(Von_Screen)
        #region "大屏接口声明"
        public interface ScreenInterface
        {
            #region "Properties"
            /// <summary>序号</summary>
            int ID { get; set; }
            /// <summary>大屏名称</summary>
            string ScreenName { get; set; }
            /// <summary>宽度</summary>
            int Width { get; set; }
            /// <summary>高度</summary>
            int Height { get; set; }
            /// <summary>更新频率单位</summary>
            string UpdateUnit { get; set; }
            /// <summary>频率值</summary>
            int UpdateTime { get; set; }
            #endregion
        }
        #endregion
        // 大屏组件(Von_ScreenItem)
        #region "大屏组件接口声明"
        public interface ScreenItemInterface
        {
            #region "Properties"
            /// <summary>序号</summary>
            int ID { get; set; }
            /// <summary>组件类型</summary>
            string ItemType { get; set; }
            /// <summary>所属大屏</summary>
            int ScreenIdx { get; set; }
            /// <summary>位置X</summary>
            int PosX { get; set; }
            /// <summary>位置Y</summary>
            int PosY { get; set; }
            /// <summary>位置X</summary>
            int Width { get; set; }
            /// <summary>位置Y</summary>
            int Height { get; set; }
            /// <summary>更新频率单位</summary>
            char UpdateUnit { get; set; }
            /// <summary>频率值</summary>
            int UpdateTime { get; set; }
            /// <summary>显示序号</summary>
            int DisplayOrder { get; set; }
            #endregion
        }
        #endregion
    }
    namespace Structs
    {
        #region 站点菜单
        /// <summary>站点菜单 信息类</summary>
        public class MenuInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public MenuInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="MenuName">菜单名称</param>
            /// <param name="PID">父节点</param>
            /// <param name="MenuClass">菜单样式</param>
            /// <param name="iconFilename">菜单图标</param>
            /// <param name="MenuData">菜单内容</param>
            public MenuInfo(Guid ID, string MenuName, Guid PID, string MenuClass, string iconFilename, string MenuData, int DisplayOrder)
            {
                this.ID = ID;
                this.MenuName = MenuName;
                this.PID = PID;
                this.MenuClass = MenuClass;
                this.iconFilename = iconFilename;
                this.MenuData = MenuData;
                this.DisplayOrder = DisplayOrder;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "站点菜单")]
            public Guid ID { get; set; }
            /// <summary>菜单名称</summary>
            [LocalDisplay("菜单名称", "站点菜单")]
            public string MenuName { get; set; }
            /// <summary>父节点</summary>
            [Required]
            [LocalDisplay("父节点", "站点菜单")]
            public Guid PID { get; set; }
            /// <summary>菜单样式</summary>
            [LocalDisplay("菜单样式", "站点菜单")]
            public string MenuClass { get; set; }
            /// <summary>菜单图标</summary>
            [LocalDisplay("菜单图标", "站点菜单")]
            public string iconFilename { get; set; }
            /// <summary>菜单内容</summary>
            [LocalDisplay("菜单内容", "站点菜单")]
            public string MenuData { get; set; }
            /// <summary>菜单内容</summary>
            [LocalDisplay("显示序号", "站点菜单")]
            public int DisplayOrder { get; set; }
            #endregion
        }
        #endregion
        #region 票证编码规则
        /// <summary>票证编码规则 信息类</summary>
        public class TicketNoInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public TicketNoInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="RuleName">规则名称</param>
            /// <param name="LastTime">最后取值时间</param>
            /// <param name="CurrentID">当前序号</param>
            /// <param name="Kind">变更类型</param>
            /// <param name="NumLength">编码长度</param>
            /// <param name="Rule">编码规则</param>
            public TicketNoInfo(string RuleName, DateTime LastTime, int CurrentID, int Kind, int NumLength, string Rule)
            {
                this.RuleName = RuleName;
                this.LastTime = LastTime;
                this.CurrentID = CurrentID;
                this.Kind = Kind;
                this.NumLength = NumLength;
                this.Rule = Rule;
            }
            #endregion
            #region "Public Properties"
            /// <summary>规则名称</summary>
            [Required]
            [LocalDisplay("规则名称", "票证编码规则")]
            public string RuleName { get; set; }
            /// <summary>最后取值时间</summary>
            [LocalDisplay("最后取值时间", "票证编码规则")]
            [JsonConverter(typeof(VonJsonDateConverer))]
            public DateTime LastTime { get; set; }
            /// <summary>当前序号</summary>
            [LocalDisplay("当前序号", "票证编码规则")]
            public int CurrentID { get; set; }
            /// <summary>变更类型</summary>
            [LocalDisplay("变更类型", "票证编码规则")]
            public int Kind { get; set; }
            /// <summary>编码长度</summary>
            [LocalDisplay("编码长度", "票证编码规则")]
            public int NumLength { get; set; }
            /// <summary>编码规则</summary>
            [LocalDisplay("编码规则", "票证编码规则")]
            public string Rule { get; set; }
            #endregion
        }
        #endregion
        #region "审批流信息类声明"
        /// <summary>审批流 信息类</summary>
        public class StateFlowInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public StateFlowInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="FlowName">流程名称</param>
            /// <param name="Kind">业务分类</param>
            /// <param name="Param">流程参数</param>
            /// <param name="Status">状态</param>
            /// <param name="Creator">创建人</param>
            /// <param name="CreateTime">创建时间</param>
            /// <param name="Modifier">修改人</param>
            /// <param name="Modifidate">修改时间</param>
            public StateFlowInfo(Guid ID, string FlowName, string Kind, string Param, string Status, Guid Creator, DateTime CreateTime, Guid Modifier, DateTime Modifidate)
            {
                this.ID = ID;
                this.FlowName = FlowName;
                this.Kind = Kind;
                this.Param = Param;
                this.Status = Status;
                this.Creator = Creator;
                this.CreateTime = CreateTime;
                this.Modifier = Modifier;
                this.Modifidate = Modifidate;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "审批流")]
            public Guid ID { get; set; }
            /// <summary>流程名称</summary>
            [LocalDisplay("流程名称", "审批流")]
            public string FlowName { get; set; }
            /// <summary>业务分类</summary>
            [LocalDisplay("业务分类", "审批流")]
            public string Kind { get; set; }
            /// <summary>流程参数</summary>
            [LocalDisplay("流程参数", "审批流")]
            public string Param { get; set; }
            /// <summary>状态</summary>
            [LocalDisplay("状态", "审批流")]
            public string Status { get; set; }
            /// <summary>创建人</summary>
            [LocalDisplay("创建人", "审批流")]
            public Guid Creator { get; set; }
            /// <summary>创建时间</summary>
            [LocalDisplay("创建时间", "审批流")]
            public DateTime CreateTime { get; set; }
            /// <summary>修改人</summary>
            [LocalDisplay("修改人", "审批流")]
            public Guid Modifier { get; set; }
            /// <summary>修改时间</summary>
            [LocalDisplay("修改时间", "审批流")]
            public DateTime Modifidate { get; set; }
            #endregion
        }
        #endregion
        #region "审批流节点信息类声明"
        /// <summary>审批流节点 信息类</summary>
        public class StateFlowItemInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public StateFlowItemInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="FlowIdx">审批方案索引</param>
            /// <param name="InStatus">进入状态</param>
            /// <param name="MethodName">处理方法</param>
            /// <param name="Style">按钮样式</param>
            /// <param name="OutStatus">处理结果</param>
            /// <param name="OutData">结果数据</param>
            public StateFlowItemInfo(Guid ID, Guid FlowIdx, string InStatus, string MethodName, string Style, string OutStatus, string OutData)
            {
                this.ID = ID;
                this.FlowIdx = FlowIdx;
                this.InStatus = InStatus;
                this.MethodName = MethodName;
                this.Style = Style;
                this.OutStatus = OutStatus;
                this.OutData = OutData;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "审批流节点")]
            public Guid ID { get; set; }
            /// <summary>审批方案索引</summary>
            [Required]
            [LocalDisplay("审批方案索引", "审批流节点")]
            public Guid FlowIdx { get; set; }
            /// <summary>进入状态</summary>
            [LocalDisplay("进入状态", "审批流节点")]
            public string InStatus { get; set; }
            /// <summary>处理方法</summary>
            [LocalDisplay("处理方法", "审批流节点")]
            public string MethodName { get; set; }
            /// <summary>按钮样式</summary>
            [LocalDisplay("按钮样式", "审批流节点")]
            public string Style { get; set; }
            /// <summary>处理结果</summary>
            [LocalDisplay("处理结果", "审批流节点")]
            public string OutStatus { get; set; }
            /// <summary>处理后事件</summary>
            [LocalDisplay("处理后事件", "结果数据")]
            public string OutData { get; set; }
            #endregion
        }
        #endregion
        #region "系统选项信息类声明"
        /// <summary>系统选项 信息类</summary>
        public class OptionInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public OptionInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="OptName">参数名称</param>
            /// <param name="OptKind">参数类型</param>
            /// <param name="OptInfo">参数说明</param>
            public OptionInfo(string OptName, int OptKind, string OptInfo)
            {
                this.OptName = OptName;
                this.OptKind = OptKind;
                this.OptInfo = OptInfo;
            }
            #endregion
            #region "Public Properties"
            [Required]
            /// <summary>参数名称</summary>
            [LocalDisplay("参数名称", "系统选项")]
            public string OptName { get; set; }
            /// <summary>参数类型</summary>
            [LocalDisplay("参数类型", "系统选项")]
            public int OptKind { get; set; }
            /// <summary>参数说明</summary>
            [LocalDisplay("参数说明", "系统选项")]
            public string OptInfo { get; set; }
            #endregion
        }
        #endregion
        #region "主页广告信息声明"
        public class SliderInfo: SliderInterface
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public SliderInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="Kind">类型</param>
            /// <param name="Title">名称</param>
            /// <param name="Import">引用资料</param>
            /// <param name="Content">内容</param>
            /// <param name="Validate">有效期</param>
            /// <param name="Linker">链接</param>
            public SliderInfo(int ID, string Kind, string Title, DateTime Validate, string Linker)
            {
                this.ID = ID;
                this.Kind = Kind;
                this.Title = Title;
                this.Validate = Validate;
                this.Linker = Linker;
            }
            #endregion
            #region "Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "系统内容")]
            public int ID { get; set; } = 0;
            /// <summary>类型</summary>
            [LocalDisplay("类型", "系统内容")]
            public string Kind { get; set; } = "";
            /// <summary>名称</summary>
            [LocalDisplay("名称", "系统内容")]
            public string Title { get; set; } = "";
            /// <summary>有效期</summary>
            [JsonConverter(typeof(VonJsonDateConverer))]
            [LocalDisplay("有效期", "系统内容")]
            public DateTime Validate { get; set; } = DateTime.MinValue;
            /// <summary>链接</summary>
            [LocalDisplay("链接", "系统内容")]
            public string Linker { get; set; } = "";
            /// <summary>显示顺序</summary>
            [LocalDisplay("显示顺序", "系统内容")]
            public int DisplayOrder { get; set; } = 0;
            #endregion
        }
        #endregion
        #region "皮肤管理信息类声明"
        /// <summary>皮肤管理 信息类</summary>
        public class SkinInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public SkinInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="SkinName">名称</param>
            /// <param name="AdminSkin">管理皮肤</param>
            /// <param name="AppSkin">应用皮肤</param>
            public SkinInfo(int ID, string SkinName, string AdminSkin, string AppSkin)
            {
                this.ID = ID;
                this.SkinName = SkinName;
                this.AdminSkin = AdminSkin;
                this.AppSkin = AppSkin;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "皮肤管理")]
            public int ID { get; set; }
            /// <summary>名称</summary>
            [LocalDisplay("名称", "皮肤管理")]
            public string SkinName { get; set; }
            /// <summary>管理皮肤</summary>
            [LocalDisplay("管理皮肤", "皮肤管理")]
            public string AdminSkin { get; set; }
            /// <summary>应用皮肤</summary>
            [LocalDisplay("应用皮肤", "皮肤管理")]
            public string AppSkin { get; set; }
            #endregion
        }
        #endregion
        #region "文本文档分类信息类声明"
        /// <summary>文本文档分类 信息类</summary>
        public class HtmlCatalogInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public HtmlCatalogInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="CatalogName">分类名称</param>
            /// <param name="PID">父级序号</param>
            /// <param name="Icon">图标</param>
            /// <param name="DisplayOrder">显示顺序</param>
            public HtmlCatalogInfo(int ID, string CatalogName, int PID, string Icon, int DisplayOrder)
            {
                this.ID = ID;
                this.CatalogName = CatalogName;
                this.PID = PID;
                this.Icon = Icon;
                this.DisplayOrder = DisplayOrder;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "文本文档分类")]
            public int ID { get; set; }
            /// <summary>分类名称</summary>
            [LocalDisplay("分类名称", "文本文档分类")]
            public string CatalogName { get; set; }
            /// <summary>父级序号</summary>
            [Required]
            [LocalDisplay("父级序号", "文本文档分类")]
            public int PID { get; set; }
            /// <summary>图标</summary>
            [LocalDisplay("图标", "文本文档分类")]
            public string Icon { get; set; }
            /// <summary>显示顺序</summary>
            [Required]
            [LocalDisplay("显示顺序", "文本文档分类")]
            public int DisplayOrder { get; set; }
            #endregion
        }
        #endregion
        #region "文本内容信息类声明"
        /// <summary>文本内容 信息类</summary>
        public class HtmlContentInfo
        {
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "文本内容")]
            public int ID { get; set; }
            /// <summary>文档名称</summary>
            [LocalDisplay("文档名称", "文本内容")]
            public string HtmlName { get; set; }
            /// <summary>状态</summary>
            [LocalDisplay("状态", "文本内容")]
            public string Status { get; set; }
            /// <summary>标题</summary>
            [LocalDisplay("标题", "文本内容")]
            public string Title { get; set; }
            /// <summary>标签</summary>
            [LocalDisplay("标签", "文本内容")]
            public string Tags { get; set; }
            /// <summary>关键词</summary>
            [LocalDisplay("关键词", "文本内容")]
            public string Keyword { get; set; }
            /// <summary>作者</summary>
            [LocalDisplay("作者", "文本内容")]
            public string Autor { get; set; }
            /// <summary>来源</summary>
            [LocalDisplay("来源", "文本内容")]
            public string Src { get; set; }
            /// <summary>链接</summary>
            [LocalDisplay("链接", "文本内容")]
            public string Linker { get; set; }
            /// <summary>发布时间</summary>
            [LocalDisplay("发布时间", "文本内容")]
            public DateTime Publishedate { get; set; }
            /// <summary>所属分类</summary>
            [Required]
            [LocalDisplay("所属分类", "文本内容")]
            public int CatalogIdx { get; set; }
            /// <summary>浏览次数</summary>
            [LocalDisplay("浏览次数", "文本内容")]
            public int BrowserCount { get; set; }
            #endregion
        }
        #endregion
        #region "评论信息类声明"
        /// <summary>评论 信息类</summary>
        public class CommentInfo
        {
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "评论")]
            public int ID { get; set; }
            /// <summary>评论文档类型</summary>
            [Required]
            [LocalDisplay("评论文档类型", "评论")]
            public string Kind { get; set; }
            /// <summary>文档序号</summary>
            [Required]
            [LocalDisplay("文档序号", "评论")]
            public string LinkIdx { get; set; }
            /// <summary>点评值</summary>
            [LocalDisplay("点评值", "评论")]
            public int Evaluation { get; set; }
            /// <summary>点评日期</summary>
            [LocalDisplay("点评日期", "评论")]
            [JsonConverter(typeof(VonJsonDateConverer))]
            public DateTime Publishedate { get; set; }
            /// <summary>点评用户</summary>
            [LocalDisplay("点评用户", "评论")]
            public Guid Publisher { get; set; }
            /// <summary>回复邮箱</summary>
            [LocalDisplay("回复邮箱", "评论")]
            public string Email { get; set; }
            /// <summary>关注</summary>
            [LocalDisplay("关注", "评论")]
            public bool Concern { get; set; }
            /// <summary>支持</summary>
            [LocalDisplay("支持", "评论")]
            public bool Support { get; set; }
            /// <summary>差评</summary>
            [LocalDisplay("差评", "评论")]
            public bool Oppose { get; set; }
            /// <summary>回复日期</summary>
            [LocalDisplay("回复日期", "评论")]
            [JsonConverter(typeof(VonJsonDateConverer))]
            public DateTime ReplyDate { get; set; }
            /// <summary>回复人</summary>
            [LocalDisplay("回复人", "评论")]
            public Guid Replyer { get; set; }
            /// <summary>评论内容</summary>
            [LocalDisplay("评论内容", "评论")]
            public string Content { get; set; }
            /// <summary>回复内容</summary>
            [LocalDisplay("回复内容", "评论")]
            public string ReplyContent { get; set; }
            #endregion
        }
        #endregion
        #region "照片资源信息类声明"
        /// <summary>照片资源 信息类</summary>
        public class ImageInfo
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public ImageInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="Kind">资源类型</param>
            /// <param name="Code">编码</param>
            /// <param name="ImageName">资源名称</param>
            /// <param name="Ext">图片类型</param>
            public ImageInfo(Guid ID, string Kind, string Code, string ImageName, string Ext)
            {
                this.ID = ID;
                this.Kind = Kind;
                this.Code = Code;
                this.ImageName = ImageName;
                this.Ext = Ext;
            }
            #endregion
            #region "Public Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "照片资源")]
            public Guid ID { get; set; }
            /// <summary>资源类型</summary>
            [Required]
            [LocalDisplay("资源类型", "照片资源")]
            public string Kind { get; set; }
            /// <summary>编码</summary>
            [Required]
            [LocalDisplay("编码", "照片资源")]
            public string Code { get; set; }
            /// <summary>资源名称</summary>
            [LocalDisplay("资源名称", "照片资源")]
            public string ImageName { get; set; }
            /// <summary>图片类型</summary>
            [LocalDisplay("图片类型", "照片资源")]
            public string Ext { get; set; }
            #endregion
        }
        #endregion
        #region "系统日志信息声明"
        public class LogInfo : LogInterface
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public LogInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="LogTime">时间</param>
            /// <param name="EventNsmr">事件</param>
            /// <param name="Level">等级</param>
            /// <param name="Content">内容</param>
            /// <param name="Operator">操作人</param>
            public LogInfo(DateTime LogTime, string EventName, int Level, string Content, string Operator)
            {
                this.LogTime = LogTime;
                this.EventName = EventName;
                this.Level = Level;
                this.Content = Content;
                this.Operator = Operator;
            }
            #endregion
            #region "Properties"
            /// <summary>时间</summary>
            [Required]
            [JsonConverter(typeof(VonJsonDatetimeConverer))]
            [LocalDisplay("时间", "系统日志")]
            public DateTime LogTime { get; set; } = DateTime.MinValue;
            /// <summary>事件</summary>
            [LocalDisplay("事件", "系统日志")]
            public string EventName { get; set; } = "";
            /// <summary>等级</summary>
            [LocalDisplay("等级", "系统日志")]
            public int Level { get; set; } = 0;
            /// <summary>内容</summary>
            [LocalDisplay("内容", "系统日志")]
            public string Content { get; set; } = "";
            /// <summary>操作人</summary>
            [LocalDisplay("操作人", "系统日志")]
            public string Operator { get; set; } = "";
            #endregion
        }
        #endregion
        #region "大屏信息声明"
        public class ScreenInfo : ScreenInterface
        {
            #region "Constructors"
            /// <summary>
            /// 构造函数
            /// </summary>
            public ScreenInfo()
            {
            }
            /// <summary>
            /// 含初始化构造函数
            /// </summary>
            /// <param name="ID">序号</param>
            /// <param name="ScreenName">大屏名称</param>
            /// <param name="Width">宽度</param>
            /// <param name="Height">高度</param>
            /// <param name="UpdateUnit">更新频率单位</param>
            /// <param name="UpdateTime">频率值</param>
            public ScreenInfo(int ID, string ScreenName, int Width, int Height, string UpdateUnit, int UpdateTime)
            {
                this.ID = ID;
                this.ScreenName = ScreenName;
                this.Width = Width;
                this.Height = Height;
                this.UpdateUnit = UpdateUnit;
                this.UpdateTime = UpdateTime;
            }
            #endregion
            #region "Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "大屏")]
            public int ID { get; set; } = 0;
            /// <summary>大屏名称</summary>
            [LocalDisplay("大屏名称", "大屏")]
            public string ScreenName { get; set; } = "";
            /// <summary>宽度</summary>
            [LocalDisplay("宽度", "大屏")]
            public int Width { get; set; } = 0;
            /// <summary>高度</summary>
            [LocalDisplay("高度", "大屏")]
            public int Height { get; set; } = 0;
            /// <summary>更新频率单位</summary>
            [LocalDisplay("更新频率单位", "大屏")]
            public string UpdateUnit { get; set; } = "";
            /// <summary>频率值</summary>
            [LocalDisplay("频率值", "大屏")]
            public int UpdateTime { get; set; } = 0;
            #endregion
        }
        #endregion
        #region "大屏组件信息声明"
        public class ScreenItemInfo : ScreenItemInterface
        {
            #region "Properties"
            /// <summary>序号</summary>
            [Required]
            [LocalDisplay("序号", "大屏组件")]
            public int ID { get; set; } = 0;
            /// <summary>组件类型</summary>
            [LocalDisplay("组件类型", "大屏组件")]
            public string ItemType { get; set; } = "";
            /// <summary>所属大屏</summary>
            [Required]
            [LocalDisplay("所属大屏", "大屏组件")]
            public int ScreenIdx { get; set; } = 0;
            /// <summary>位置X</summary>
            [LocalDisplay("位置X", "大屏组件")]
            public int PosX { get; set; } = 0;
            /// <summary>位置Y</summary>
            [LocalDisplay("位置Y", "大屏组件")]
            public int PosY { get; set; } = 0;
            /// <summary>位置X</summary>
            [LocalDisplay("宽度", "大屏组件")]
            public int Width { get; set; } = 0;
            /// <summary>位置Y</summary>
            [LocalDisplay("高度", "大屏组件")]
            public int Height { get; set; } = 0;
            /// <summary>更新频率单位</summary>
            [LocalDisplay("更新频率单位", "大屏组件")]
            public char UpdateUnit { get; set; } = '无';
            /// <summary>频率值</summary>
            [LocalDisplay("频率值", "大屏组件")]
            public int UpdateTime { get; set; } = 1;
            /// <summary>显示序号</summary>
            [LocalDisplay("显示序号", "大屏组件")]
            public int DisplayOrder { get; set; } = 0;
            #endregion
        }
        #endregion
    }
    namespace Tasks
    {
        #region 站点菜单
        /// <summary>站点菜单 控制类</summary>
        /// <seealso cref="Von.Portal.Models.MenuInfo"/>
        public class MenuTask
        {
            protected MenuAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public MenuTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<MenuAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, MenuInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.MenuName = reader.GetString(1);  //菜单名称
                info.PID = reader.GetGuid(2);  //父节点
                info.MenuClass = reader.GetString(3);  //菜单样式
                info.iconFilename = reader.GetString(4);  //菜单图标
                info.MenuData = reader.GetString(5);  //菜单内容
                info.DisplayOrder = reader.GetInt32(6);  //显示序号
            }
            /// <summary>检验Menu信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : MenuInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Menu 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByMenu<T>(Guid ID) where T : MenuInfo, new()
            {
                IDataReader reader = dbAccess.GetByMenu(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 站点菜单 信息</summary>
            public async Task<List<T>> List<T>() where T : MenuInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_Menu_PID 提取信息</summary>
            /// <param name="PID">父节点</param>
            public async Task<List<T>> ListByMenu_PID<T>(Guid PID) where T : MenuInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByMenu_PID(PID);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_Menu_PID 提取信息</summary>
            /// <param name="PID">父节点</param>
            public async Task<List<MenuViewModel>> ListByMenuWithRight(Guid PID, string RoleName)
            {
                List<MenuViewModel> list = new List<MenuViewModel>();
                IDataReader reader = dbAccess.ListByMenuWithRight(PID, RoleName);
                while (reader.Read())
                {
                    //ID MenuName    PID DisplayOrder (无列名)
                    MenuViewModel info = new MenuViewModel();
                    info.ID = reader.GetGuid(0);  //序号
                    info.MenuName = reader.GetString(1);  //菜单名称
                    info.PID = reader.GetGuid(2);  //父节点
                    info.DisplayOrder = reader.GetInt32(3);  //显示序号
                    info.Checked = reader.GetInt32(4) > 0;  //权限
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            public async Task<bool> Move(Guid ID, int newOrder)
            {
                return dbAccess.Move(ID, newOrder) > 0;
            }
            /// <summary>添加Menu信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : MenuInfo, new()
            {
                return dbAccess.Add(info.ID, info.MenuName, info.PID, info.MenuClass, info.iconFilename, info.MenuData, info.DisplayOrder) > 0;
            }
            /// <summary>修改Menu信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : MenuInfo, new()
            {
                return dbAccess.Edit(info.ID, info.MenuName, info.PID, info.MenuClass, info.iconFilename, info.MenuData, info.DisplayOrder) > 0;
            }
            /// <summary>根据PK_Menu删除Menu信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }
        }
        #endregion
        #region 票证编码规则
        /// <summary>票证编码规则 控制类</summary>
        /// <seealso cref="Von.Web.Models.TicketNoInfo"/>
        public class TicketNoTask
        {
            protected TicketNoAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public TicketNoTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<TicketNoAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, TicketNoInfo info)
            {
                info.RuleName = reader.GetString(0);  //规则名称
                info.LastTime = reader.GetDateTime(1); ;  //最后取值时间
                info.CurrentID = reader.GetInt32(2);  //当前序号
                info.Kind = reader.GetInt32(3);  //变更类型
                info.NumLength = reader.GetInt32(4);  //编码长度
                info.Rule = reader.GetString(5);  //编码规则
            }
            /// <summary>检验TicketNo信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : TicketNoInfo, new()
            {
                if (string.IsNullOrEmpty(info.RuleName)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "规则名称");
                return ExecuteResult.Success(true);
            }
            public static async Task<string> GetTicketNo(string RuleName)
            {
                TicketNoTask task = new TicketNoTask();
                TicketNoInfo info = await task.GetByTicketNo<TicketNoInfo>(RuleName);
                if (info == null) return RuleName + "未设置";
                DateTime currDate = DateTime.Now;
                string No = await GetTicketNo(info, currDate);
                info.LastTime = currDate;
                info.CurrentID++;
                await task.Edit(info);
                return No;
            }
            public static async Task<string> GetTicketNo(TicketNoInfo info, DateTime currDate)
            {
                switch (info.Kind)
                {
                    case 0: if (currDate.Year > info.LastTime.Year) info.CurrentID = 1; break;   //year
                    case 1: if (currDate.Year * 12 + currDate.Month > info.LastTime.Year * 12 + info.LastTime.Month) info.CurrentID = 1; break;   //month
                    case 2: if ((currDate - info.LastTime).Days > 0) info.CurrentID = 1; break;   //day
                    case 3: if ((currDate - info.LastTime).Days > 0 || currDate.Hour - info.LastTime.Hour > 0) info.CurrentID = 1; break;   //hour
                }
                return string.Format(info.Rule, info.CurrentID, currDate.Year % 100, currDate.Year, currDate.Month, currDate.Day, currDate.Hour);
            }
            /// <summary>
            /// 根据主键 PK_TicketNo 提取信息
            /// </summary>
            /// <param name="RuleName">规则名称</param>
            public async Task<T> GetByTicketNo<T>(string RuleName) where T : TicketNoInfo, new()
            {
                IDataReader reader = dbAccess.GetByTicketNo(RuleName);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 票证编码规则 信息</summary>
            public async Task<List<T>> List<T>() where T : TicketNoInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加TicketNo信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : TicketNoInfo, new()
            {
                return dbAccess.Add(info.RuleName, info.LastTime, info.CurrentID, info.Kind, info.NumLength, info.Rule) > 0;
            }
            /// <summary>修改TicketNo信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : TicketNoInfo, new()
            {
                return dbAccess.Edit(info.RuleName, info.LastTime, info.CurrentID, info.Kind, info.NumLength, info.Rule) > 0;
            }
            /// <summary>根据PK_TicketNo删除TicketNo信息</summary>
            /// <param name="RuleName">规则名称</param>
            public async Task<bool> Del(string RuleName)
            {
                return dbAccess.Del(RuleName) > 0;
            }

        }
        #endregion
        #region "审批流信息基础控制类声明"
        /// <summary>审批流 控制类</summary>
        /// <seealso cref="Von.Portal.Models.StateFlowInfo"/>
        public class StateFlowTask
        {
            protected StateFlowAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public StateFlowTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<StateFlowAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, StateFlowInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.FlowName = reader.GetString(1);  //流程名称
                info.Kind = reader.GetString(2);  //业务分类
                info.Param = reader.GetString(3);  //流程参数
                info.Status = reader.GetString(4);  //状态
                info.Creator = reader.GetGuid(5);  //创建人
                info.CreateTime = reader.GetDateTime(6); ;  //创建时间
                info.Modifier = reader.GetGuid(7);  //修改人
                info.Modifidate = reader.GetDateTime(8); ;  //修改时间
            }
            /// <summary>检验StateFlow信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : StateFlowInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_StateFlow 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByStateFlow<T>(Guid ID) where T : StateFlowInfo, new()
            {
                IDataReader reader = dbAccess.GetByStateFlow(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>
            /// 根据主键 PK_StateFlow 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByStateFlow<T>(string Kind, string FlowName) where T : StateFlowInfo, new()
            {
                IDataReader reader = dbAccess.GetByStateFlow(Kind, FlowName);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 审批流 信息</summary>
            public async Task<List<T>> List<T>() where T : StateFlowInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加StateFlow信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : StateFlowInfo, new()
            {
                return dbAccess.Add(info.ID, info.FlowName, info.Kind, info.Param, info.Status, info.Creator, info.CreateTime, info.Modifier, info.Modifidate) > 0;
            }
            /// <summary>修改StateFlow信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : StateFlowInfo, new()
            {
                return dbAccess.Edit(info.ID, info.FlowName, info.Kind, info.Param, info.Status, info.Creator, info.CreateTime, info.Modifier, info.Modifidate) > 0;
            }
            /// <summary>根据PK_StateFlow删除StateFlow信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }

            public async Task<bool> UpdateSetting(Guid ID, string data)
            {
                return dbAccess.UpdateSetting(ID, data) > 0;
            }
            public async Task<string> LoadSetting(Guid ID)
            {
                return dbAccess.LoadSetting(ID);
            }
        }
        #endregion
        #region "审批流节点信息基础控制类声明"
        /// <summary>审批流节点 控制类</summary>
        /// <seealso cref="Von.Portal.Models.StateFlowItemInfo"/>
        public class StateFlowItemTask
        {
            protected StateFlowItemAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public StateFlowItemTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<StateFlowItemAccess>(DBTrans);
            }

            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, StateFlowItemInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.FlowIdx = reader.GetGuid(1);  //审批方案索引
                info.InStatus = reader.GetString(2);  //进入状态
                info.MethodName = reader.GetString(3);  //处理方法
                info.Style = reader.GetString(4);  //按钮样式
                info.OutStatus = reader.GetString(5);  //处理结果
                info.OutData = reader.GetString(6);  //结果数据
            }
            /// <summary>检验StateFlowItem信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : StateFlowItemInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_StateFlowItem 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByStateFlowItem<T>(Guid ID) where T : StateFlowItemInfo, new()
            {
                IDataReader reader = dbAccess.GetByStateFlowItem(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>
            /// 根据主键 PK_StateFlowItem 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetStateFlowItemByMethod<T>(Guid ID, string Method) where T : StateFlowItemInfo, new()
            {
                IDataReader reader = dbAccess.GetByStateFlowItemByMethod(ID, Method);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 审批流节点 信息</summary>
            public async Task<List<T>> List<T>() where T : StateFlowItemInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_StateFlowItem 提取信息</summary>
            /// <param name="FlowIdx">审批方案索引</param>
            public async Task<List<T>> ListByStateFlowItem<T>(Guid FlowIdx) where T : StateFlowItemInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByStateFlowItem(FlowIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_ITEM_REF_STATEFLOW 提取信息</summary>
            public async Task<List<T>> ListByStatus<T>(Guid FlowIdx, string CurrentStatus) where T : StateFlowItemInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListMethods(FlowIdx, CurrentStatus);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加StateFlowItem信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add<T>(T info) where T : StateFlowItemInfo, new()
            {
                return dbAccess.Add(info.ID, info.FlowIdx, info.InStatus, info.MethodName, info.Style, info.OutStatus, info.OutData) > 0;
            }
            /// <summary>修改StateFlowItem信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit<T>(T info) where T : StateFlowItemInfo, new()
            {
                return dbAccess.Edit(info.ID, info.FlowIdx, info.InStatus, info.MethodName, info.InStatus, info.OutStatus, info.OutData) > 0;
            }
            /// <summary>根据PK_StateFlowItem删除StateFlowItem信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_ITEM_REF_STATEFLOW删除StateFlowItem信息</summary>
            ///<param name="FlowIdx">审批方案索引</param>
            public async Task<bool> DelFlow(Guid FlowIdx)
            {
                return dbAccess.DelFlow(FlowIdx) > 0;
            }

        }
        #endregion
        #region "系统选项信息基础控制类声明"
        /// <summary>系统选项 控制类</summary>
        /// <seealso cref="Von.Web.Models.OptionInfo"/>
        public class OptionTask
        {
            private static OptionTask _task = new OptionTask();
            public static OptionTask Instance()
            {
                return _task;
            }
            protected OptionAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public OptionTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<OptionAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, OptionInfo info)
            {
                info.OptName = reader.GetString(0);  //参数名称
                info.OptKind = reader.GetInt32(1);  //参数类型
                info.OptInfo = reader.GetString(2);  //参数说明
            }
            /// <summary>检验Option信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : OptionInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_OPTION 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByOPTION<T>(string OptName) where T : OptionInfo, new()
            {
                IDataReader reader = dbAccess.GetByOPTION(OptName);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>得到参数值信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="OptValues">参数值</param>
            public async Task<string> GetOptValues(string OptName)
            {
                return dbAccess.GetOptValues(OptName);
            }
            public async Task<string[]> GetOptValueArray(string OptName)
            {
                return dbAccess.GetOptValues(OptName).Split(Environment.NewLine.ToCharArray(), StringSplitOptions.None);
            }
            public async Task<VonKeyValueCollection> GetOptKeyValue(string OptName)
            {
                string[] arr = dbAccess.GetOptValues(OptName).Split(Environment.NewLine.ToCharArray(), StringSplitOptions.None);
                VonKeyValueCollection lst = new VonKeyValueCollection();
                foreach(string s in arr)
                {
                    string[] v = s.Split('=');
                    lst.Add(v[0], v[1]);
                }
                return lst;
            }
            /// <summary>编辑参数值信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="OptValues">参数值</param>
            public async Task<bool> SetOptValues(string OptName, string OptValues)
            {
                return dbAccess.SetOptValues(OptName, OptValues) > 0;
            }
            /// <summary>提取所有 系统选项 信息</summary>
            public async Task<List<T>> List<T>() where T : OptionInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加Option信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(OptionInfo info)
            {
                return dbAccess.Add(info.OptName, info.OptKind, info.OptInfo) > 0;
            }
            /// <summary>修改Option信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(OptionInfo info)
            {
                return dbAccess.Edit(info.OptName, info.OptKind, info.OptInfo) > 0;
            }
            /// <summary>根据PK_OPTION删除Option信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(string OptName)
            {
                return dbAccess.Del(OptName) > 0;
            }

        }
        #endregion
        #region "系统服务信息基础控制类声明"
        /// <summary>系统服务 控制类</summary>
        /// <seealso cref="Von.Web.Models.ServiceInfo"/>
        /// <summary>系统服务 控制类</summary>
        /// <seealso cref="Von.Web.Models.ServiceInfo"/>
        public class ServiceTask
        {
            protected ServiceAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public ServiceTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<ServiceAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, WebServiceBase info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.ServiceName = reader.GetString(1);  //服务名称
                info.InterKind = (ServiceInterKind)reader.GetInt32(2);  //间隔方式
                info.Intervalue = reader.GetInt32(3);  //间隔值
                info.Necessary = reader.GetBoolean(4);  //必要性
                info.Status = reader.GetString(5);  //状态
                info.Param = reader.GetString(6);  //运行参数
            }
            /// <summary>
            /// 根据主键 PK_Service 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task GetServceModel(WebServiceBase model)
            {
                IDataReader reader = dbAccess.GetByService(model.ID);
                if (reader.Read())
                {
                    setInfoValue(reader, model);
                }
                reader.Close();
                return;
            }
            /// <summary>添加Service信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Save(WebServiceBase info)
            {
                return dbAccess.Save(info.ID, info.ServiceName, (int)info.InterKind, info.Intervalue, info.Necessary, info.Status, info.Param) > 0;
            }
        }
        #endregion
        #region "主页广告信息基础控制类声明"
        /// <summary>主页广告 控制类</summary>
        /// <seealso cref="Von.Web.Models.SliderInfo"/>
        /// <summary>主页广告 控制类</summary>
        /// <seealso cref="VonPortal.Web.Models.SliderInfo"/>
        public class SliderTask
        {
            protected SliderAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public SliderTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<SliderAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, SliderInterface info)
            {
                info.ID = (int)reader["ID"];  //序号
                info.Kind = (string)reader["Kind"];  //类型
                info.Title = (string)reader["Title"];  //名称
                info.Validate = (DateTime)reader["Validate"];  //有效期
                info.Linker = (string)reader["Linker"];  //链接
                info.DisplayOrder = (int)reader["DisplayOrder"];  //链接
                if (info is SliderModel)
                {
                    (info as SliderModel).Import = (string)reader["Import"];  //引用资料
                    (info as SliderModel).Content = (string)reader["Content"];  //内容
                }
            }
            /// <summary>检验Slider信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : SliderInterface, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_SLIDER 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<SliderModel> GetBySLIDER(int ID)
            {
                IDataReader reader = dbAccess.GetBySLIDER(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                SliderModel info = new SliderModel();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>得到引用资料信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Import">引用资料</param>
            public async Task<string> GetImport(int ID)
            {
                return dbAccess.GetImport(ID);
            }
            /// <summary>编辑引用资料信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Import">引用资料</param>
            public async Task<bool> SetImport(int ID, string Import)
            {
                return dbAccess.SetImport(ID, Import) > 0;
            }
            /// <summary>得到内容信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Content">内容</param>
            public async Task<string> GetContent(int ID)
            {
                return dbAccess.GetContent(ID);
            }
            /// <summary>编辑内容信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Content">内容</param>
            public async Task<bool> SetContent(int ID, string Content)
            {
                return dbAccess.SetContent(ID, Content) > 0;
            }
            /// <summary>提取所有 主页广告 信息</summary>
            public async Task<List<T>> List<T>(string Kind) where T : SliderInterface, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List(Kind);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            public async Task<List<T>> Search<T>(JObject ConditionJson) where T : SliderInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.Search(ConditionJson);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>保存Slider信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Save<T>(T info) where T : SliderModel, new()
            {
                if (info.ID == 0) return await Add(info);
                else return await Edit(info);
            }
            /// <summary>添加Slider信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(SliderModel info)
            {
                info.ID = dbAccess.Add(info.Kind, info.Title, info.Import, info.Content, info.Validate, info.Linker, info.DisplayOrder);
                Runtime.Log.InfoFormat("添加主页广告{0}", info.ID);
                return info.ID > 0;
            }
            /// <summary>修改Slider信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(SliderModel info)
            {
                int effect = dbAccess.Edit(info.ID, info.Kind, info.Title, info.Import, info.Content, info.Validate, info.Linker, info.DisplayOrder);
                Runtime.Log.InfoFormat("修改主页广告{0}", info.ID);
                return effect > 0;
            }
            /// <summary>根据PK_SLIDER删除Slider信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                int effect = dbAccess.Del(ID);
                Runtime.Log.InfoFormat("根据PK_SLIDER删除主页广告{0}", ID);
                return effect > 0;
            }
        }
        #endregion
        #region "皮肤管理信息基础控制类声明"
        /// <summary>皮肤管理 控制类</summary>
        /// <seealso cref="Von.Web.Models.SkinInfo"/>
        public class SkinTask
        {
            protected SkinAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public SkinTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<SkinAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, SkinInfo info)
            {
                info.ID = reader.GetInt32(0);  //序号
                info.SkinName = reader.GetString(1);  //名称
                info.AdminSkin = reader.GetString(2);  //管理皮肤
                info.AppSkin = reader.GetString(3);  //应用皮肤
            }
            /// <summary>检验Skin信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : SkinInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Skin 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetBySkin<T>(int ID) where T : SkinInfo, new()
            {
                IDataReader reader = dbAccess.GetBySkin(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 皮肤管理 信息</summary>
            public async Task<List<T>> List<T>() where T : SkinInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加Skin信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(SkinInfo info)
            {
                info.ID = dbAccess.Add(info.SkinName, info.AdminSkin, info.AppSkin);
                return info.ID > 0;
            }
            /// <summary>修改Skin信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(SkinInfo info)
            {
                return dbAccess.Edit(info.ID, info.SkinName, info.AdminSkin, info.AppSkin) > 0;
            }
            /// <summary>根据PK_Skin删除Skin信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }
        }
        #endregion
        #region "文本文档分类信息基础控制类声明"
        /// <summary>文本文档分类 控制类</summary>
        /// <seealso cref="Von.Web.Models.HtmlCatalogInfo"/>
        public class HtmlCatalogTask
        {
            protected HtmlCatalogAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public HtmlCatalogTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<HtmlCatalogAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, HtmlCatalogInfo info)
            {
                info.ID = reader.GetInt32(0);  //序号
                info.CatalogName = reader.GetString(1);  //分类名称
                info.PID = reader.GetInt32(2);  //父级序号
                info.Icon = reader.GetString(3);  //图标
                info.DisplayOrder = reader.GetInt32(4);  //显示顺序
            }
            /// <summary>检验HtmlCatalog信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : HtmlCatalogInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_HtmlCatalog 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByHtmlCatalog<T>(int ID) where T : HtmlCatalogInfo, new()
            {
                IDataReader reader = dbAccess.GetByHtmlCatalog(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>
            /// 根据名称查找到当前目录
            /// </summary>
            /// <param name="PID">父级序号</param>
            /// <param name="name">目录层次名称，每层以小数点分割</param>
            public async Task<HtmlCatalogInfo> FindHtmlCatalog(int PID, string name)
            {
                IDataReader reader = dbAccess.FindHtmlCatalog(PID, name);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                HtmlCatalogInfo info = new HtmlCatalogInfo();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>提取所有 文本文档分类 信息</summary>
            public async Task<List<T>> List<T>() where T : HtmlCatalogInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_HtmlCatalog 提取信息</summary>
            /// <param name="PID">父级序号</param>
            /// <param name="DisplayOrder">显示顺序</param>
            public async Task<List<T>> ListByPID<T>(int PID) where T : HtmlCatalogInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByPID(PID);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>移动HtmlCatalog信息</summary>
            ///<param name="ID">信息键值</param>
            ///<param name="newOrder">新位置序号</param>
            ///<seealso>
            /// create procedure MOVE_HtmlCatalog
            ///    @ID int,
            ///    @NewOrder int
            ///    as begin
            ///    	DECLARE @OldOrd int
            ///    	DECLARE @PID int
            ///    	SELECT @OldOrd=DisplayOrder,@PID=PID FROM Von_HtmlCatalog WHERE ID=@ID
            ///    	IF(@OldOrd<@NewOrder)BEGIN
            ///    		UPDATE Von_HtmlCatalog SET DisplayOrder=DisplayOrder-1 WHERE PID=@PID AND DisplayOrder>@OldOrd AND DisplayOrder<=@NewOrder
            ///    	END ELSE BEGIN
            ///    		UPDATE Von_HtmlCatalog SET DisplayOrder=DisplayOrder+1 WHERE PID=@PID AND DisplayOrder<@OldOrd AND DisplayOrder>=@NewOrder
            ///    	END
            ///    	UPDATE Von_HtmlCatalog SET DisplayOrder=@NewOrder WHERE ID=@ID
            ///    end
            ///</seealso>
            public async Task<bool> Move(int ID, int newOrder)
            {
                return dbAccess.Move(ID, newOrder) > 0;
            }
            /// <summary>添加HtmlCatalog信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(HtmlCatalogInfo info)
            {
                info.ID = dbAccess.Add(info.CatalogName, info.PID, info.Icon, info.DisplayOrder);
                return info.ID > 0;
            }
            /// <summary>修改HtmlCatalog信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(HtmlCatalogInfo info)
            {
                return dbAccess.Edit(info.ID, info.CatalogName, info.PID, info.Icon, info.DisplayOrder) > 0;
            }
            /// <summary>根据PK_HtmlCatalog删除HtmlCatalog信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }

        }
        #endregion
        #region "文本内容信息基础控制类声明"
        /// <summary>文本内容 控制类</summary>
        /// <seealso cref="Von.Web.Models.HtmlContentInfo"/>
        public class HtmlContentTask
        {
            protected HtmlContentAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public HtmlContentTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<HtmlContentAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, HtmlContentInfo info)
            {
                info.ID = reader.GetInt32(0);  //序号
                info.HtmlName = reader.GetString(1);  //文档名称
                info.Status = reader.GetString(2);  //状态
                info.Title = reader.GetString(3);  //标题
                info.Tags = reader.GetString(4);  //标签
                info.Keyword = reader.GetString(5);  //关键词
                info.Autor = reader.GetString(6);  //作者
                info.Src = reader.GetString(7);  //来源
                info.Linker = reader.GetString(8);  //链接
                info.Publishedate = reader.GetDateTime(9);  //发布时间
                info.CatalogIdx = reader.GetInt32(10);  //所属分类
                info.BrowserCount = reader.GetInt32(11);  //浏览次数
            }
            /// <summary>检验HtmlContent信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : HtmlContentInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_HtmlContent 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByHtmlContent<T>(int ID) where T : HtmlContentInfo, new()
            {
                IDataReader reader = dbAccess.GetByHtmlContent(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>
            /// 根据目录和资料名称提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> FindHtmlContent<T>(int PID, string name) where T : HtmlContentInfo, new()
            {
                IDataReader reader = dbAccess.FindHtmlContent(PID, name);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>得到摘要信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Summary">摘要</param>
            public async Task<string> GetSummary(int ID)
            {
                return dbAccess.GetSummary(ID);
            }
            /// <summary>编辑摘要信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Summary">摘要</param>
            public async Task<bool> SetSummary(int ID, string Summary)
            {
                return dbAccess.SetSummary(ID, Summary) > 0;
            }
            /// <summary>得到正文信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Content">正文</param>
            public async Task<string> GetContent(int ID)
            {
                return dbAccess.GetContent(ID);
            }
            /// <summary>编辑正文信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Content">正文</param>
            public async Task<bool> SetContent(int ID, string Content)
            {
                return dbAccess.SetContent(ID, Content) > 0;
            }
            /// <summary>提取所有 文本内容 信息</summary>
            public async Task<List<T>> List<T>() where T : HtmlContentInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 FK_CONTENT_REF_HTMLCATALOG 提取信息</summary>
            public async Task<List<T>> ListByCONTENT_REF_HTMLCATALOG<T>(int CatalogIdx, int Cnt = 0, string Status = null) where T : HtmlContentInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByCONTENT_REF_HTMLCATALOG(CatalogIdx, Cnt, Status);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加HtmlContent信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(HtmlContentInfo info)
            {
                info.ID = dbAccess.Add(info.HtmlName, info.Title, info.Tags, info.Keyword, info.Autor, info.Src, info.Linker, info.CatalogIdx);
                return info.ID > 0;
            }
            /// <summary>修改HtmlContent信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Publish(int ID)
            {
                return dbAccess.Publish(ID) > 0;
            }
            /// <summary>修改HtmlContent信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(HtmlContentInfo info)
            {
                return dbAccess.Edit(info.ID, info.HtmlName, info.Title, info.Tags, info.Keyword, info.Autor, info.Src, info.Linker) > 0;
            }
            /// <summary>根据PK_HtmlContent删除HtmlContent信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }
            /// <summary>根据FK_CONTENT_REF_HTMLCATALOG删除HtmlContent信息</summary>
            ///<param name="CatalogIdx">所属分类</param>
            public async Task<bool> DelCatalog(int CatalogIdx)
            {
                return dbAccess.DelCatalog(CatalogIdx) > 0;
            }
        }
        #endregion
        #region "评论信息基础控制类声明"
        /// <summary>评论 控制类</summary>
        /// <seealso cref="Von.Web.Models.CommentInfo"/>
        public class CommentTask
        {
            protected CommentAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public CommentTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<CommentAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, CommentInfo info)
            {
                info.ID = reader.GetInt32(0);               //序号
                info.Kind = reader.GetString(1);            //评论文档类型
                info.LinkIdx = reader.GetString(2);         //文档序号
                info.Evaluation = reader.GetInt32(3);       //点评值
                info.Publishedate = reader.GetDateTime(4);  //点评日期
                info.Publisher = reader.GetGuid(5);         //点评用户
                info.Email = reader.GetString(6);           //回复邮箱
                info.Concern = reader.GetBoolean(7);        //关注
                info.Support = reader.GetBoolean(8);        //支持
                info.Oppose = reader.GetBoolean(9);         //差评
                info.ReplyDate = reader.IsDBNull(10) ? DateTime.MinValue : reader.GetDateTime(10);    //回复日期
                info.Replyer = reader.IsDBNull(11) ? Guid.Empty : reader.GetGuid(11);          //回复人
                info.Content = reader.GetString(12);        //评论内容
                info.ReplyContent = reader.IsDBNull(13) ? "" : reader.GetString(13);   //回复内容
            }
            /// <summary>检验Comment信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : CommentInfo, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Comment 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByComment<T>(int ID) where T : CommentInfo, new()
            {
                IDataReader reader = dbAccess.GetByComment(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>根据索引 IDX_Comment 提取信息</summary>
            /// <param name="Kind">评论文档类型</param>

            /// <param name="LinkIdx">文档序号</param>
            public async Task<List<T>> ListByComment<T>(string Kind, string LinkIdx) where T : CommentInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByComment(Kind, LinkIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加Comment信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(CommentInfo info)
            {
                info.ID = dbAccess.Add(info.Kind, info.LinkIdx, info.Evaluation, info.Publisher, info.Email, info.Concern, info.Support, info.Oppose, info.Content);
                return info.ID > 0;
            }
            public async Task<bool> ReplyComment(int ID, Guid Replyer, string ReplyContent)
            {
                return dbAccess.ReplyComment(ID, Replyer, ReplyContent) > 0;
            }
            /// <summary>根据PK_Comment删除Comment信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                return dbAccess.Del(ID) > 0;
            }

        }
        #endregion
        #region "照片资源信息基础控制类声明"
        /// <summary>照片资源 控制类</summary>
        /// <seealso cref="PCDC.Web.Models.Von_ImageInfo"/>
        public class ImageTask
        {
            protected ImageAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public ImageTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<ImageAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, ImageInfo info)
            {
                info.ID = reader.GetGuid(0);  //序号
                info.Kind = reader.GetString(1);  //资源类型
                info.Code = reader.GetString(2);  //编码
                info.ImageName = reader.GetString(3);  //资源名称
                info.Ext = reader.GetString(4);  //图片类型
            }
            /// <summary>检验Von_Image信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : ImageInfo, new()
            {
                /// <summary>根据索引 IDX_Image 提取信息</summary>
                if (string.IsNullOrEmpty(info.Kind)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "资源类型");
                /// <summary>根据索引 IDX_Image 提取信息</summary>
                if (string.IsNullOrEmpty(info.Code)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "编码");
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Image 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByImage<T>(Guid ID) where T : ImageInfo, new()
            {
                IDataReader reader = dbAccess.GetByImage(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>得到图片信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Img">图片</param>
            public async Task<byte[]> GetImg(Guid ID)
            {
                return dbAccess.GetImg(ID);
            }
            /// <summary>编辑图片信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Img">图片</param>
            public async Task<bool> SetImg(Guid ID, Stream Img)
            {
                return dbAccess.SetImg(ID, Img) > 0;
            }
            /// <summary>提取所有 照片资源 信息</summary>
            public async Task<List<T>> List<T>() where T : ImageInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_Image 提取信息</summary>
            /// <param name="Kind">资源类型</param>

            /// <param name="Code">编码</param>
            public async Task<T> GetByImage<T>(string Kind, string Code) where T : ImageInfo, new()
            {
                IDataReader reader = dbAccess.GetByImage(Kind, Code);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }

            /// <summary>添加Von_Image信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(ImageInfo info)
            {
                return dbAccess.Add(info.ID, info.Kind, info.Code, info.ImageName, info.Ext) > 0;
            }
            /// <summary>修改Von_Image信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(ImageInfo info)
            {
                return dbAccess.Edit(info.ID, info.Kind, info.Code, info.ImageName, info.Ext) > 0;
            }
            /// <summary>根据PK_Image删除Von_Image信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(Guid ID)
            {
                return dbAccess.Del(ID) > 0;
            }
        }
        #endregion
        #region "系统日志信息基础控制类声明"
        /// <summary>系统日志 控制类</summary>
        /// <seealso cref="Von.Web.Models.LogInfo"/>
        public class LogTask
        {
            protected LogAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public LogTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<LogAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, LogInterface info)
            {
                info.LogTime = (DateTime)reader["LogTime"];  //时间
                info.EventName = (string)reader["EventName"];  //事件
                info.Level = (int)reader["Level"];  //等级
                info.Content = (string)reader["Content"];  //内容
                info.Operator = (string)reader["Operator"];  //操作人
            }
            /// <summary>检验Log信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : LogInterface, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>提取所有 系统日志 信息</summary>
            public async Task<List<T>> List<T>() where T : LogInterface, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据索引 IDX_Log 提取信息</summary>
            /// <param name="LogTime">时间</param>
            public async Task<List<T>> ListByLog<T>(DateTime LogTime) where T : LogInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByLog(LogTime);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            public async Task<List<T>> Search<T>(JObject ConditionJson) where T : LogInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.Search(ConditionJson);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>添加Log信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(LogInfo info)
            {
                int effect = dbAccess.Add(info.LogTime, info.EventName, info.Level, info.Content, info.Operator);
                return effect > 0;
            }
            /// <summary>修改Log信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(LogInfo info)
            {
                int effect = dbAccess.Edit(info.LogTime, info.EventName, info.Level, info.Content, info.Operator);
                return effect > 0;
            }
            /// <summary>删除此前所有日志</summary>
            ///<param name="firstDate">删除此前所有日志</param>
            public async Task<bool> Empty(DateTime firstDate)
            {
                int effect = dbAccess.Delete(firstDate);
                return effect > 0;
            }
        }
        #endregion
        #region "大屏信息基础控制类声明"
        /// <summary>大屏 控制类</summary>
        /// <seealso cref="Join.Web.Models.ScreenInfo"/>
        public class ScreenTask
        {
            protected ScreenAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public ScreenTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<ScreenAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, ScreenInterface info)
            {
                info.ID = (int)reader["ID"];  //序号
                info.ScreenName = (string)reader["ScreenName"];  //大屏名称
                info.Width = (int)reader["Width"];  //宽度
                info.Height = (int)reader["Height"];  //高度
                info.UpdateUnit = (string)reader["UpdateUnit"];  //更新频率单位
                info.UpdateTime = (int)reader["UpdateTime"];  //频率值
                if (info is ScreenModel)
                {
                    (info as ScreenModel).Style = (string)reader["Style"];  //私有样式
                }
            }
            /// <summary>检验Screen信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : ScreenInterface, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Von_Screen 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByVon_Screen<T>(int ID) where T : ScreenInfo, new()
            {
                IDataReader reader = dbAccess.GetByVon_Screen(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>得到私有样式信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Style">私有样式</param>
            public async Task<string> GetStyle(int ID)
            {
                return dbAccess.GetStyle(ID);
            }
            /// <summary>编辑私有样式信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Style">私有样式</param>
            public async Task<bool> SetStyle(int ID, string Style)
            {
                return dbAccess.SetStyle(ID, Style) > 0;
            }
            /// <summary>提取所有 大屏 信息</summary>
            public async Task<List<T>> List<T>() where T : ScreenInterface, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.List();
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>自定义查询Screen信息</summary>
            /// <param name="ConditionJson">查询条件</param>
            /// <remarks>
            ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
            ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
            ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
            ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
            ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
            ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
            ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
            /// </remarks>
            /// <example>
            ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
            ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
            /// </example>
            public async Task<List<T>> Search<T>(JObject ConditionJson) where T : ScreenInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.Search(ConditionJson);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>保存Screen信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Save<T>(T info) where T : ScreenModel, new()
            {
                if (info.ID == 0) return await Add(info);
                else return await Edit(info);
            }
            /// <summary>添加Screen信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(ScreenModel info)
            {
                info.ID = dbAccess.Add(info.ScreenName, info.Width, info.Height, info.UpdateUnit, info.UpdateTime, info.Style);
                Runtime.Log.InfoFormat("添加大屏{0}", info.ID);
                return info.ID > 0;
            }
            /// <summary>修改Screen信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(ScreenModel info)
            {
                int effect = dbAccess.Edit(info.ID, info.ScreenName, info.Width, info.Height, info.UpdateUnit, info.UpdateTime, info.Style);
                Runtime.Log.InfoFormat("修改大屏{0}", info.ID);
                return effect > 0;
            }
            /// <summary>根据PK_Von_Screen删除Screen信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                int effect = dbAccess.Del(ID);
                Runtime.Log.InfoFormat("根据PK_Von_Screen删除大屏{0}", ID);
                return effect > 0;
            }
        }
        #endregion
        #region "大屏组件信息基础控制类声明"
        /// <summary>大屏组件 控制类</summary>
        /// <seealso cref="Join.Web.Models.ScreenItemInfo"/>
        /// <summary>大屏组件 控制类</summary>
        /// <seealso cref="Join.Web.Models.ScreenItemInfo"/>
        public class ScreenItemTask
        {
            protected ScreenItemAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public ScreenItemTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<ScreenItemAccess>(DBTrans);
            }
            //Read data and write to AgentInfo class
            protected void setInfoValue(IDataReader reader, ScreenItemInterface info)
            {
                info.ID = (int)reader["ID"];  //序号
                info.ItemType = (string)reader["ItemType"];  //组件类型
                info.ScreenIdx = (int)reader["ScreenIdx"];  //所属大屏
                info.PosX = (int)reader["PosX"];  //位置X
                info.PosY = (int)reader["PosY"];  //位置Y
                info.Width = (int)reader["Width"];  //宽度
                info.Height = (int)reader["Height"];  //高度
                info.UpdateUnit = (char)reader["UpdateUnit"];  //更新频率单位
                info.UpdateTime = (int)reader["UpdateTime"];  //频率值
                info.DisplayOrder = (int)reader["DisplayOrder"];  //显示序号
                if (info is ScreenItemModel)
                {
                    (info as ScreenItemModel).Style = (string)reader["Style"];  //样式
                    (info as ScreenItemModel).SampleData = (string)reader["SampleData"];  //样例数据
                    (info as ScreenItemModel).Setting = JObject.Parse((string)reader["Setting"]);  //设置参数
                }
            }
            /// <summary>检验ScreenItem信息</summary>
            public async Task<ExecuteResult> Check<T>(T info) where T : ScreenItemInterface, new()
            {
                return ExecuteResult.Success(true);
            }
            /// <summary>
            /// 根据主键 PK_Von_ScreenItem 提取信息
            /// </summary>
            /// <param name="ID">序号</param>
            public async Task<T> GetByVon_ScreenItem<T>(int ID) where T : ScreenItemInfo, new()
            {
                IDataReader reader = dbAccess.GetByVon_ScreenItem(ID);
                if (!reader.Read())
                {
                    reader.Close();
                    return null;
                }
                T info = new T();
                setInfoValue(reader, info);
                reader.Close();
                return info;
            }
            /// <summary>得到样式信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Style">样式</param>
            public async Task<string> GetStyle(int ID)
            {
                return dbAccess.GetStyle(ID);
            }
            /// <summary>编辑样式信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Style">样式</param>
            public async Task<bool> SetStyle(int ID, string Style)
            {
                return dbAccess.SetStyle(ID, Style) > 0;
            }
            /// <summary>得到样例数据信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="SampleData">样例数据</param>
            public async Task<string> GetSampleData(int ID)
            {
                return dbAccess.GetSampleData(ID);
            }
            /// <summary>编辑样例数据信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="SampleData">样例数据</param>
            public async Task<bool> SetSampleData(int ID, string SampleData)
            {
                return dbAccess.SetSampleData(ID, SampleData) > 0;
            }
            /// <summary>得到设置参数信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="SampleData">样例数据</param>
            public async Task<string> GetSetting(int ID)
            {
                return dbAccess.GetSetting(ID);
            }
            /// <summary>编辑设置参数信息</summary>
            ///<param name="ID">序号</param>
            ///<param name="Setting">设置参数</param>
            public async Task<bool> SetSetting(int ID, string Setting)
            {
                return dbAccess.SetSetting(ID, Setting) > 0;
            }
            /// <summary>自定义查询ScreenItem信息</summary>
            /// <param name="ConditionJson">查询条件</param>
            /// <remarks>
            ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
            ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
            ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
            ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
            ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
            ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
            ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
            ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
            /// </remarks>
            /// <example>
            ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
            ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
            /// </example>
            public async Task<List<T>> Search<T>(JObject ConditionJson) where T : ScreenItemInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.Search(ConditionJson);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>根据外键 组件关联大屏 提取信息</summary>
            public async Task<List<T>> ListByITEM_REF_SCREEN<T>(int ScreenIdx) where T : ScreenItemInfo, new()
            {
                List<T> list = new List<T>();
                IDataReader reader = dbAccess.ListByITEM_REF_SCREEN(ScreenIdx);
                while (reader.Read())
                {
                    T info = new T();
                    setInfoValue(reader, info);
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
            /// <summary>保存ScreenItem信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Save<T>(T info) where T : ScreenItemModel, new()
            {
                if (info.ID == 0) return await Add(info);
                else return await Edit(info);
            }
            /// <summary>添加ScreenItem信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Add(ScreenItemModel info)
            {
                info.ID = dbAccess.Add(info.ItemType, info.ScreenIdx, info.PosX, info.PosY, info.Width, info.Height, info.UpdateUnit, info.UpdateTime, info.Style, info.Setting.ToString(), info.SampleData, info.DisplayOrder);
                Runtime.Log.InfoFormat("添加大屏组件{0}", info.ID);
                return info.ID > 0;
            }
            /// <summary>修改ScreenItem信息</summary>
            ///<param name="info">信息类</param>
            public async Task<bool> Edit(ScreenItemModel info)
            {
                int effect = dbAccess.Edit(info.ID, info.ItemType, info.ScreenIdx, info.PosX, info.PosY, info.Width, info.Height, info.UpdateUnit, info.UpdateTime, info.Style, info.Setting.ToString(), info.SampleData, info.DisplayOrder);
                Runtime.Log.InfoFormat("修改大屏组件{0}", info.ID);
                return effect > 0;
            }
            /// <summary>根据PK_Von_ScreenItem删除ScreenItem信息</summary>
            /// <param name="ID">序号</param>
            public async Task<bool> Del(int ID)
            {
                int effect = dbAccess.Del(ID);
                Runtime.Log.InfoFormat("根据PK_Von_ScreenItem删除大屏组件{0}", ID);
                return effect > 0;
            }
            /// <summary>根据组件关联大屏删除ScreenItem信息</summary>
            ///<param name="ScreenIdx">所属大屏</param>
            public async Task<bool> DelScreen(int ScreenIdx)
            {
                int effect = dbAccess.DelScreen(ScreenIdx);
                Runtime.Log.InfoFormat("根据组件关联大屏删除大屏组件{0}", ScreenIdx);
                return effect > 0;
            }
        }
        #endregion
    }
    namespace Datas
    {
        #region MenuAccess
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Portal.Models.MenuInfo"/>
        /// <seealso cref="Von.Portal.Operators.MenuCtrl"/>
        public abstract class MenuAccess : DBAccessBase
        {
            #region "Menu Abstract Methods"
            /// <summary>根据主键 PK_Menu 提取信息</summary>
            public abstract IDataReader GetByMenu(Guid ID);
            /// <summary>根据主键 站点菜单 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据索引 IDX_Menu_PID 提取信息</summary>
            public abstract IDataReader ListByMenu_PID(Guid PID);
            /// <summary>根据索引 IDX_Menu_PID 提取信息</summary>
            public abstract IDataReader ListByMenuWithRight(Guid PID, string RoleName);
            /// <summary>移动一个节点显示位置</summary>
            public abstract int Move(Guid ID, int newOrder);
            /// <summary>添加Menu信息</summary>
            public abstract int Add(Guid ID, string MenuName, Guid PID, string MenuClass, string iconFilename, string MenuData, int DisplayOrder);
            /// <summary>修改Menu信息</summary>
            public abstract int Edit(Guid ID, string MenuName, Guid PID, string MenuClass, string iconFilename, string MenuData, int DisplayOrder);
            /// <summary>根据PK_Menu删除Menu信息</summary>
            public abstract int Del(Guid ID);
            #endregion
        }
        #endregion
        #region TicketNoAccess
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.TicketNoInfo"/>
        /// <seealso cref="Von.Web.Operators.TicketNoCtrl"/>
        public abstract class TicketNoAccess : DBAccessBase
        {
            #region "TicketNo Abstract Methods"
            /// <summary>根据主键 PK_TicketNo 提取信息</summary>
            public abstract IDataReader GetByTicketNo(string RuleName);
            /// <summary>根据主键 票证编码规则 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>添加TicketNo信息</summary>
            public abstract int Add(string RuleName, DateTime LastTime, int CurrentID, int Kind, int NumLength, string Rule);
            /// <summary>修改TicketNo信息</summary>
            public abstract int Edit(string RuleName, DateTime LastTime, int CurrentID, int Kind, int NumLength, string Rule);
            /// <summary>根据PK_TicketNo删除TicketNo信息</summary>
            public abstract int Del(string RuleName);
            #endregion
        }
        #endregion
        #region "审批流信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Portal.Models.StateFlowInfo"/>
        /// <seealso cref="Von.Portal.Operators.StateFlowCtrl"/>
        public abstract class StateFlowAccess : DBAccessBase
        {
            #region "StateFlow Abstract Methods"
            /// <summary>根据主键 PK_StateFlow 提取信息</summary>
            public abstract IDataReader GetByStateFlow(Guid ID);
            /// <summary>根据分类和名称提取信息</summary>
            public abstract IDataReader GetByStateFlow(string Kind, string FlowName);
            /// <summary>根据主键 审批流 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>添加StateFlow信息</summary>
            public abstract int Add(Guid ID, string FlowName, string Kind, string Param, string Status, Guid Creator, DateTime CreateTime, Guid Modifier, DateTime Modifidate);
            /// <summary>修改StateFlow信息</summary>
            public abstract int Edit(Guid ID, string FlowName, string Kind, string Param, string Status, Guid Creator, DateTime CreateTime, Guid Modifier, DateTime Modifidate);
            /// <summary>修改StateFlow设置信息</summary>
            public abstract int UpdateSetting(Guid ID, string Setting);
            /// <summary>获取StateFlow设置信息</summary>
            public abstract string LoadSetting(Guid iD);
            /// <summary>根据PK_StateFlow删除StateFlow信息</summary>
            public abstract int Del(Guid ID);
            #endregion
        }
        #endregion
        #region "审批流节点信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Portal.Models.StateFlowItemInfo"/>
        /// <seealso cref="Von.Portal.Operators.StateFlowItemCtrl"/>
        public abstract class StateFlowItemAccess : DBAccessBase
        {
            #region "StateFlowItem Abstract Methods"
            /// <summary>根据主键 PK_StateFlowItem 提取信息</summary>
            public abstract IDataReader GetByStateFlowItem(Guid ID);
            /// <summary>根据主键 审批流节点 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据索引 IDX_StateFlowItem 提取信息</summary>
            public abstract IDataReader ListByStateFlowItem(Guid FlowIdx);
            /// <summary>根据外键 FK_ITEM_REF_STATEFLOW 提取信息</summary>
            public abstract IDataReader ListByITEM_REF_STATEFLOW(Guid FlowIdx);
            /// <summary>获取流程下某一状态的</summary>
            public abstract IDataReader ListMethods(Guid FlowIdx, string CurrentStatus);
            /// <summary>添加StateFlowItem信息</summary>
            public abstract int Add(Guid ID, Guid FlowIdx, string InStatus, string MethodName, string Style, string OutStatus, string OutData);
            /// <summary>修改StateFlowItem信息</summary>
            public abstract int Edit(Guid ID, Guid FlowIdx, string InStatus, string MethodName, string Style, string OutStatus, string OutData);
            /// <summary>根据PK_StateFlowItem删除StateFlowItem信息</summary>
            public abstract int Del(Guid ID);
            /// <summary>根据FK_ITEM_REF_STATEFLOW删除StateFlowItem信息</summary>
            public abstract int DelFlow(Guid FlowIdx);
            public abstract IDataReader GetByStateFlowItemByMethod(Guid iD, string method);
            #endregion
        }
        #endregion
        #region "审批流节点状态信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Join.Web.Models.StateFlowStatusInfo"/>
        /// <seealso cref="Join.Web.Operators.StateFlowStatusCtrl"/>
        public abstract class StateFlowStatusAccess : DBAccessBase
        {
            #region "StateFlowStatus Abstract Methods"
            /// <summary>提取 审批流节点状态 列表</summary>
            public abstract IDataReader List();
            /// <summary>查询 审批流节点状态 列表</summary>
            public abstract IDataReader Search(JObject ConditionJson);
            /// <summary>根据索引 IDX_StateFlowItem 提取信息</summary>
            public abstract IDataReader GetByStateFlowItem(Guid FlowIdx, string Status);
            /// <summary>添加StateFlowStatus信息</summary>
            public abstract int Add(Guid FlowIdx, string Condition, string Status);
            /// <summary>修改StateFlowStatus信息</summary>
            public abstract int Edit(Guid FlowIdx, string Condition, string Status);
            #endregion
        }
        #endregion
        #region "系统选项信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.OptionInfo"/>
        /// <seealso cref="Von.Web.Operators.OptionCtrl"/>
        public abstract class OptionAccess : DBAccessBase
        {
            #region "Option Abstract Methods"
            /// <summary>根据主键 PK_OPTION 提取信息</summary>
            public abstract IDataReader GetByOPTION(string OptName);
            /// <summary>编辑参数值信息</summary>
            ///<param name="int ID>序号</param>
            public abstract string GetOptValues(string OptName);
            /// <summary>编辑参数值信息</summary>
            public abstract int SetOptValues(string OptName, string OptValues);
            /// <summary>根据主键 系统选项 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>添加Option信息</summary>
            public abstract int Add(string OptName, int OptKind, string OptInfo);
            /// <summary>修改Option信息</summary>
            public abstract int Edit(string OptName, int OptKind, string OptInfo);
            /// <summary>根据PK_OPTION删除Option信息</summary>
            public abstract int Del(string OptName);
            #endregion
        }
        #endregion
        #region "系统服务信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.ServiceInfo"/>
        /// <seealso cref="Von.Web.Operators.ServiceCtrl"/>
        public abstract class ServiceAccess : DBAccessBase
        {
            #region "Service Abstract Methods"
            /// <summary>根据主键 PK_Service 提取信息</summary>
            public abstract IDataReader GetByService(Guid ID);
            /// <summary>添加Service信息</summary>
            public abstract int Save(Guid ID, string ServiceName, int InterKind, int Intervalue, bool Necessary, string Status, string Param);
            #endregion
        }
        #endregion
        #region "主页广告信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.SliderInfo"/>
        /// <seealso cref="Von.Web.Operators.SliderCtrl"/>
        public abstract class SliderAccess : DBAccessBase
        {
            #region "Slider Abstract Methods"
            /// <summary>根据主键 PK_SLIDER 提取信息</summary>
            public abstract IDataReader GetBySLIDER(int ID);
            /// <summary>编辑引用资料信息</summary>
            ///<param name="ID">序号</param>
            public abstract string GetImport(int ID);
            /// <summary>编辑引用资料信息</summary>
            public abstract int SetImport(int ID, string Import);
            /// <summary>编辑内容信息</summary>
            ///<param name="ID">序号</param>
            public abstract string GetContent(int ID);
            /// <summary>编辑内容信息</summary>
            public abstract int SetContent(int ID, string Content);
            /// <summary>提取 主页广告 列表</summary>
            public abstract IDataReader List(string Kind);
            /// <summary>查询 主页广告 列表</summary>
            public abstract IDataReader Search(JObject ConditionJson);
            /// <summary>添加Slider信息</summary>
            public abstract int Add(string Kind, string Title, string Import, string Content, DateTime Validate, string Linker, int DisplayOrder);
            /// <summary>修改Slider信息</summary>
            public abstract int Edit(int ID, string Kind, string Title, string Import, string Content, DateTime Validate, string Linker, int DisplayOrder);
            /// <summary>根据PK_SLIDER删除Slider信息</summary>
            public abstract int Del(int ID);
            #endregion
        }
        #endregion
        #region "皮肤管理信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.SkinInfo"/>
        /// <seealso cref="Von.Web.Operators.SkinCtrl"/>
        public abstract class SkinAccess : DBAccessBase
        {
            #region "Skin Abstract Methods"
            /// <summary>根据主键 PK_Skin 提取信息</summary>
            public abstract IDataReader GetBySkin(int ID);
            /// <summary>根据主键 皮肤管理 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>添加Skin信息</summary>
            public abstract int Add(string SkinName, string AdminSkin, string AppSkin);
            /// <summary>修改Skin信息</summary>
            public abstract int Edit(int ID, string SkinName, string AdminSkin, string AppSkin);
            /// <summary>根据PK_Skin删除Skin信息</summary>
            public abstract int Del(int ID);
            #endregion
        }
        #endregion
        #region "文本文档分类信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.HtmlCatalogInfo"/>
        /// <seealso cref="Von.Web.Operators.HtmlCatalogCtrl"/>
        public abstract class HtmlCatalogAccess : DBAccessBase
        {
            #region "HtmlCatalog Abstract Methods"
            /// <summary>根据主键 PK_HtmlCatalog 提取信息</summary>
            public abstract IDataReader GetByHtmlCatalog(int ID);
            /// <summary>根据主键 文本文档分类 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据索引 IDX_HtmlCatalog 提取信息</summary>
            public abstract IDataReader ListByPID(int PID);
            /// <summary>移动一个节点显示位置</summary>
            public abstract int Move(int ID, int newOrder);
            /// <summary>添加HtmlCatalog信息</summary>
            public abstract int Add(string CatalogName, int PID, string Icon, int DisplayOrder);
            /// <summary>修改HtmlCatalog信息</summary>
            public abstract int Edit(int ID, string CatalogName, int PID, string Icon, int DisplayOrder);
            /// <summary>根据PK_HtmlCatalog删除HtmlCatalog信息</summary>
            public abstract int Del(int ID);
            /// <summary>
            /// 根据名称查找到当前目录
            /// </summary>
            public abstract IDataReader FindHtmlCatalog(int PID, string name);
            #endregion
        }
        #endregion
        #region "文本内容信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.HtmlContentInfo"/>
        /// <seealso cref="Von.Web.Operators.HtmlContentCtrl"/>
        public abstract class HtmlContentAccess : DBAccessBase
        {
            #region "HtmlContent Abstract Methods"
            /// <summary>根据主键 PK_HtmlContent 提取信息</summary>
            public abstract IDataReader GetByHtmlContent(int ID);
            /// <summary>编辑摘要信息</summary>
            ///<param name="int ID>序号</param>
            public abstract string GetSummary(int ID);
            /// <summary>编辑摘要信息</summary>
            public abstract int SetSummary(int ID, string Summary);
            /// <summary>编辑正文信息</summary>
            ///<param name="int ID>序号</param>
            public abstract string GetContent(int ID);
            /// <summary>编辑正文信息</summary>
            public abstract int SetContent(int ID, string Content);
            /// <summary>根据主键 文本内容 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据外键 FK_CONTENT_REF_HTMLCATALOG 提取信息</summary>
            public abstract IDataReader ListByCONTENT_REF_HTMLCATALOG(int CatalogIdx, int Cnt, string Status);
            /// <summary>添加HtmlContent信息</summary>
            public abstract int Add(string HtmlName, string Title, string Tags, string Keyword, string Autor, string Src, string Linker, int CatalogIdx);
            /// <summary>修改HtmlContent信息</summary>
            public abstract int Edit(int ID, string HtmlName, string Title, string Tags, string Keyword, string Autor, string Src, string Linker);
            /// <summary>根据PK_HtmlContent删除HtmlContent信息</summary>
            public abstract int Del(int ID);
            /// <summary>根据FK_CONTENT_REF_HTMLCATALOG删除HtmlContent信息</summary>
            public abstract int DelCatalog(int CatalogIdx);
            public abstract int Publish(int iD);
            public abstract IDataReader FindHtmlContent(int pID, string name);
            #endregion
        }
        #endregion
        #region "评论信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.CommentInfo"/>
        /// <seealso cref="Von.Web.Operators.CommentCtrl"/>

        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.CommentInfo"/>
        /// <seealso cref="Von.Web.Operators.CommentCtrl"/>
        public abstract class CommentAccess : DBAccessBase
        {
            #region "Comment Abstract Methods"
            /// <summary>根据主键 PK_Comment 提取信息</summary>
            public abstract IDataReader GetByComment(int ID);
            /// <summary>根据索引 IDX_Comment 提取信息</summary>
            public abstract IDataReader ListByComment(string Kind, string LinkIdx);
            /// <summary>添加Comment信息</summary>
            public abstract int Add(string Kind, string LinkIdx, int Evaluation, Guid Publisher, string Email, bool Concern, bool Support, bool Oppose, string Content);
            /// <summary>根据PK_Comment删除Comment信息</summary>
            public abstract int Del(int ID);
            public abstract int ReplyComment(int ID, Guid replyer, string replyContent);
            #endregion
        }
        #endregion
        #region "照片资源信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="PCDC.Web.Models.Von_ImageInfo"/>
        /// <seealso cref="PCDC.Web.Operators.Von_ImageCtrl"/>
        public abstract class ImageAccess : DBAccessBase
        {
            #region "Von_Image Abstract Methods"
            /// <summary>根据主键 PK_Image 提取信息</summary>
            public abstract IDataReader GetByImage(Guid ID);
            /// <summary>编辑图片信息</summary>
            ///<param name="int ID>序号</param>
            public abstract byte[] GetImg(Guid ID);
            /// <summary>编辑图片信息</summary>
            public abstract int SetImg(Guid ID, Stream Img);
            /// <summary>根据主键 照片资源 提取信息</summary>
            public abstract IDataReader List();
            /// <summary>根据索引 IDX_Image 提取信息</summary>
            public abstract IDataReader GetByImage(string Kind, string Code);
            /// <summary>添加Von_Image信息</summary>
            public abstract int Add(Guid ID, string Kind, string Code, string ImageName, string Ext);
            /// <summary>修改Von_Image信息</summary>
            public abstract int Edit(Guid ID, string Kind, string Code, string ImageName, string Ext);
            /// <summary>根据PK_Image删除Von_Image信息</summary>
            public abstract int Del(Guid ID);
            #endregion
        }
        #endregion
        #region "系统日志信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Von.Web.Models.LogInfo"/>
        /// <seealso cref="Von.Web.Operators.LogCtrl"/>
        public abstract class LogAccess : DBAccessBase
        {
            #region "Log Abstract Methods"
            /// <summary>提取 系统日志 列表</summary>
            public abstract IDataReader List();
            /// <summary>查询 系统日志 列表</summary>
            public abstract IDataReader Search(JObject ConditionJson);
            /// <summary>根据索引 IDX_Log 提取信息</summary>
            public abstract IDataReader ListByLog(DateTime LogTime);
            /// <summary>添加Log信息</summary>
            public abstract int Add(DateTime LogTime, string EventName, int Level, string Content, string Operator);
            /// <summary>修改Log信息</summary>
            public abstract int Edit(DateTime LogTime, string EventName, int Level, string Content, string Operator);
            /// <summary>清除数据库中系统日志</summary>
            public abstract int Delete(DateTime firstDate);
            #endregion
        }
        #endregion
        #region "大屏信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Join.Web.Models.ScreenInfo"/>
        /// <seealso cref="Join.Web.Operators.ScreenCtrl"/>
        public abstract class ScreenAccess : DBAccessBase
        {
            #region "Screen Abstract Methods"
            /// <summary>根据主键 PK_Von_Screen 提取信息</summary>
            public abstract IDataReader GetByVon_Screen(int ID);
            /// <summary>编辑私有样式信息</summary>
            ///<param name="int ID>序号</param>
            public abstract string GetStyle(int ID);
            /// <summary>编辑私有样式信息</summary>
            public abstract int SetStyle(int ID, string Style);
            /// <summary>提取 大屏 列表</summary>
            public abstract IDataReader List();
            /// <summary>查询 大屏 列表</summary>
            public abstract IDataReader Search(JObject ConditionJson);
            /// <summary>添加Screen信息</summary>
            public abstract int Add(string ScreenName, int Width, int Height, string Background, int UpdateTime, string Style);
            /// <summary>修改Screen信息</summary>
            public abstract int Edit(int ID, string ScreenName, int Width, int Height, string Background, int UpdateTime, string Style);
            /// <summary>根据PK_Von_Screen删除Screen信息</summary>
            public abstract int Del(int ID);
            #endregion
        }
        #endregion
        #region "大屏组件信息数据库访问基类声明"
        /// <summary>
        /// 数据及操作控制层
        /// </summary>
        /// <seealso cref="Join.Web.Models.ScreenItemInfo"/>
        /// <seealso cref="Join.Web.Operators.ScreenItemCtrl"/>
        public abstract class ScreenItemAccess : DBAccessBase
        {
            #region "ScreenItem Abstract Methods"
            /// <summary>根据主键 PK_Von_ScreenItem 提取信息</summary>
            public abstract IDataReader GetByVon_ScreenItem(int ID);
            /// <summary>编辑样式信息</summary>
            ///<param name="int ID>序号</param>
            public abstract string GetStyle(int ID);
            /// <summary>编辑样式信息</summary>
            public abstract int SetStyle(int ID, string Style);
            /// <summary>编辑样例数据信息</summary>
            ///<param name="int ID>序号</param>
            public abstract string GetSampleData(int ID);
            /// <summary>编辑样例数据信息</summary>
            public abstract int SetSampleData(int ID, string SampleData);
            public abstract string GetSetting(int ID);
            public abstract int SetSetting(int ID, string setting);
            /// <summary>查询 大屏组件 列表</summary>
            public abstract IDataReader Search(JObject ConditionJson);
            /// <summary>根据外键 组件关联大屏 提取信息</summary>
            public abstract IDataReader ListByITEM_REF_SCREEN(int ScreenIdx);
            /// <summary>添加ScreenItem信息</summary>
            public abstract int Add(string ItemType, int ScreenIdx, int PosX, int PosY, int Width, int Height, char UpdateUnit, int UpdateTime, string Style, string Setting, string SampleData, int DisplayOrder);
            /// <summary>修改ScreenItem信息</summary>
            public abstract int Edit(int ID, string ItemType, int ScreenIdx, int PosX, int PosY, int Width, int Height, char UpdateUnit, int UpdateTime, string Style, string Setting, string SampleData, int DisplayOrder);
            /// <summary>根据PK_Von_ScreenItem删除ScreenItem信息</summary>
            public abstract int Del(int ID);
            /// <summary>根据组件关联大屏删除ScreenItem信息</summary>
            public abstract int DelScreen(int ScreenIdx);
            #endregion
        }
        #endregion
    }
}
#endregion
//数据库表字典（Mail and Sms）
#region "Mail and Sms 设置内容及应用接口"
namespace Von.Web.Models
{
    public interface IEmailSender
    {
        Task SendMailAsync(string Email, string Subject, string Message);
        Task SendMailAsync(string Sender, string SenderCaption, string Reciver, string ReciverCaption, string Title, string Message);
    }
    /// <summary>
    /// 邮箱和短信发送设置
    /// </summary>
    public class MailSender : IEmailSender
    {
        public MailSender()
        {
            var app = Runtime.Portal;
            JObject setting = (JObject)app.AppSetting["EmailSetting"];
            Host = setting["Host"]?.ToString();
            Port = int.Parse(setting["Port"]?.ToString());
            Timeout = int.Parse(setting["Timeout"]?.ToString());
            UseDefaultCredentials = setting["UseDefaultCredentials"]?.ToString() == "True";
            TargetName = setting["TargetName"]?.ToString();
            Account = setting["Account"]?.ToString();
            Password = setting["Password"]?.ToString();
            EnableSsl = setting["EnableSsl"]?.ToString() == "True";
            //Encode = Encoding.GetEncoding(setting["Encoding"]?.ToString());
        }
        //
        // 摘要:
        //     Gets or sets a System.Boolean value that controls whether the System.Net.CredentialCache.DefaultCredentials
        //     are sent with requests.
        //
        // 返回结果:
        //     true if the default credentials are used; otherwise false. The default value
        //     is false.
        //
        // 异常:
        //   T:System.InvalidOperationException:
        //     You cannot change the value of this property when an email is being sent.
        public bool UseDefaultCredentials { get; set; }
        //
        // 摘要:
        //     Gets or sets a value that specifies the amount of time after which a synchronous
        //     Overload:System.Net.Mail.SmtpClient.Send call times out.
        //
        // 返回结果:
        //     An System.Int32 that specifies the time-out value in milliseconds. The default
        //     value is 100,000 (100 seconds).
        //
        // 异常:
        //   T:System.ArgumentOutOfRangeException:
        //     The value specified for a set operation was less than zero.
        //
        //   T:System.InvalidOperationException:
        //     You cannot change the value of this property when an email is being sent.
        public int Timeout { get; set; }
        //
        // 摘要:
        //     Gets or sets the Service Provider Name (SPN) to use for authentication when using
        //     extended protection.
        //
        // 返回结果:
        //     A System.String that specifies the SPN to use for extended protection. The default
        //     value for this SPN is of the form &quot;SMTPSVC/&lt;host&gt;&quot; where &lt;host&gt;
        //     is the hostname of the SMTP mail server.
        public string TargetName { get; set; }
        //
        // 摘要:
        //     Gets or sets the port used for SMTP transactions.
        //
        // 返回结果:
        //     An System.Int32 that contains the port number on the SMTP host. The default value
        //     is 25.
        //
        // 异常:
        //   T:System.ArgumentOutOfRangeException:
        //     The value specified for a set operation is less than or equal to zero.
        //
        //   T:System.InvalidOperationException:
        //     You cannot change the value of this property when an email is being sent.
        public int Port { get; set; }
        //
        // 摘要:
        //     Gets or sets the folder where applications save mail messages to be processed
        //     by the local SMTP server.
        //
        // 返回结果:
        //     A System.String that specifies the pickup directory for mail messages.
        public string PickupDirectoryLocation { get; set; }
        //
        // 摘要:
        //     Gets or sets the name or IP address of the host used for SMTP transactions.
        //
        // 返回结果:
        //     A System.String that contains the name or IP address of the computer to use for
        //     SMTP transactions.
        //
        // 异常:
        //   T:System.ArgumentNullException:
        //     The value specified for a set operation is null.
        //
        //   T:System.ArgumentException:
        //     The value specified for a set operation is equal to System.String.Empty (&quot;&quot;).
        //
        //   T:System.InvalidOperationException:
        //     You cannot change the value of this property when an email is being sent.
        public string Host { get; set; }
        //
        // 摘要:
        //     Specify whether the System.Net.Mail.SmtpClient uses Secure Sockets Layer (SSL)
        //     to encrypt the connection.
        //
        // 返回结果:
        //     true if the System.Net.Mail.SmtpClient uses SSL; otherwise, false. The default
        //     is false.
        public bool EnableSsl { get; set; }
        public string Account { get; set; }
        public string Password { get; set; }
        public Encoding Encode { get; set; }
        public string SMSUrl { get; set; }
        public async Task SendMailAsync(string Email, string Subject, string Message)
        {
            await SendMailAsync(Account, "系统", Email, Email, Subject, Message);
        }

        public async Task SendMailAsync(string Sender, string SenderCaption, string Reciver, string ReciverCaption, string Title, string Message)
        {
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;//指定电子邮件发送方式    
            client.Host = Host;//邮件服务器
            client.UseDefaultCredentials = true;
            client.Credentials = new System.Net.NetworkCredential(Sender, Password);//用户名、密码
            //client.ClientCertificates.Add()

            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.From = new System.Net.Mail.MailAddress(Sender, SenderCaption);
            msg.To.Add(Reciver);
            //msg.CC.Add(strcc);

            msg.Subject = Title;//邮件标题   
            msg.Body = Message;//邮件内容   
            msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码   
            msg.IsBodyHtml = true;//是否是HTML邮件   
            msg.Priority = System.Net.Mail.MailPriority.High;//邮件优先级   

            try
            {
                client.Send(msg);
                Runtime.Log.DebugFormat("向“{0}”发送“{1}”成功", Reciver, Title);
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                Runtime.Log.ErrorFormat("向“{0}”发送“{1}”出错：{2}", Reciver, Title, ex.Message);
            }
        }
    }
}
#endregion
#region "系统辅助信息"
// 行政区划(Von_AdministrativeDistrict)
#region "行政区划接口声明"
namespace Von.Web.Apis
{
    public interface AdministrativeDistrictInterface
    {
        #region "Properties"
        /// <summary>区划编码</summary>
        string Code { get; set; }
        /// <summary>名称</summary>
        string ADName { get; set; }
        /// <summary>层级</summary>
        int Level { get; set; }
        #endregion
    }
}
#endregion
#region "行政区划信息声明"
namespace Von.Web.Structs
{
    public class AdministrativeDistrictInfo: AdministrativeDistrictInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public AdministrativeDistrictInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="Code">区划编码</param>
        /// <param name="ADName">名称</param>
        /// <param name="Level">层级</param>
        public AdministrativeDistrictInfo(string Code, string ADName, int Level)
        {
            this.Code = Code;
            this.ADName = ADName;
            this.Level = Level;
        }
        #endregion
        #region "Properties"
        /// <summary>区划编码</summary>
        [Required]
        [LocalDisplay("区划编码", "行政区划")]
        public string Code { get; set; } = "";
        /// <summary>名称</summary>
        [LocalDisplay("名称", "行政区划")]
        public string ADName { get; set; } = "";
        /// <summary>层级</summary>
        [LocalDisplay("层级", "行政区划")]
        public int Level { get; set; } = 0;
        #endregion
    }
}
#endregion    
#region "行政区划信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>行政区划 控制类</summary>
    /// <seealso cref="Von.Web.Models.AdministrativeDistrictInfo"/>
    public class AdministrativeDistrictTask
    {
        protected AdministrativeDistrictAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public AdministrativeDistrictTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<AdministrativeDistrictAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected int setInfoValue(IDataReader reader, AdministrativeDistrictInterface info, int idx = 0)
        {
            info.Code = reader.GetString(idx++);  //区划编码
            info.ADName = reader.GetString(idx++);  //名称
            info.Level = reader.GetInt32(idx++);  //层级
            return idx;
        }
        /// <summary>检验AdministrativeDistrict信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : AdministrativeDistrictInterface, new()
        {
            if (string.IsNullOrEmpty(info.Code)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "区划编码");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_AdministrativeDistrict 提取信息
        /// </summary>
        /// <param name="Code">区划编码</param>
        public async Task<AdministrativeDistrictInfo> GetByAdministrativeDistrict(string Code)
        {
            IDataReader reader = dbAccess.GetByAdministrativeDistrict(Code);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            AdministrativeDistrictInfo info = new AdministrativeDistrictInfo();
            int idx = setInfoValue(reader, info, 0);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 行政区划 信息</summary>
        public async Task<List<AdministrativeDistrictInfo>> List(int level)
        {
            List<AdministrativeDistrictInfo> list = new List<AdministrativeDistrictInfo>();
            IDataReader reader = dbAccess.List(level);
            while (reader.Read())
            {
                AdministrativeDistrictInfo info = new AdministrativeDistrictInfo();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>提取所有 行政区划 信息</summary>
        public async Task<List<AdministrativeDistrictInfo>> List(string parentCode)
        {
            List<AdministrativeDistrictInfo> list = new List<AdministrativeDistrictInfo>();
            IDataReader reader = dbAccess.List(parentCode);
            while (reader.Read())
            {
                AdministrativeDistrictInfo info = new AdministrativeDistrictInfo();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        public async Task<List<AdministrativeDistrictInfo>> Search(JObject ConditionJson)
        {
            List<AdministrativeDistrictInfo> list = new List<AdministrativeDistrictInfo>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                AdministrativeDistrictInfo info = new AdministrativeDistrictInfo();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>添加AdministrativeDistrict信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(AdministrativeDistrictInfo info)
        {
            int effect = dbAccess.Add(info.Code, info.ADName, info.Level);
            Runtime.Log.InfoFormat("添加行政区划{0}", info.Code);
            return effect > 0;
        }
        /// <summary>修改AdministrativeDistrict信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(AdministrativeDistrictInfo info)
        {
            int effect = dbAccess.Edit(info.Code, info.ADName, info.Level);
            Runtime.Log.InfoFormat("修改行政区划{0}", info.Code);
            return effect > 0;
        }
        /// <summary>根据PK_AdministrativeDistrict删除AdministrativeDistrict信息</summary>
        /// <param name="Code">区划编码</param>
        public async Task<bool> Del(string Code)
        {
            int effect = dbAccess.Del(Code);
            Runtime.Log.InfoFormat("根据PK_AdministrativeDistrict删除行政区划{0}", Code);
            return effect > 0;
        }
    }
}
#endregion
#region "行政区划信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="Von.Web.Models.AdministrativeDistrictInfo"/>
    /// <seealso cref="Von.Web.Operators.AdministrativeDistrictCtrl"/>
    public abstract class AdministrativeDistrictAccess : DBAccessBase
    {
        #region "AdministrativeDistrict Abstract Methods"
        /// <summary>根据主键 PK_AdministrativeDistrict 提取信息</summary>
        public abstract IDataReader GetByAdministrativeDistrict(string Code);
        /// <summary>提取 行政区划 列表</summary>
        public abstract IDataReader List(int level);
        /// <summary>提取 行政区划 列表</summary>
        public abstract IDataReader List(string parentCode);
        /// <summary>查询 行政区划 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>添加AdministrativeDistrict信息</summary>
        public abstract int Add(string Code, string ADName, int Level);
        /// <summary>修改AdministrativeDistrict信息</summary>
        public abstract int Edit(string Code, string ADName, int Level);
        /// <summary>根据PK_AdministrativeDistrict删除AdministrativeDistrict信息</summary>
        public abstract int Del(string Code);
        #endregion
    }
}
#endregion
// 企业信息(Von_Enterprise)
#region "企业信息接口声明"
namespace Von.Web.Apis
{
    public interface EnterpriseInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        Guid ID { get; set; }
        /// <summary>税号</summary>
        string Tax { get; set; }
        /// <summary>企业全称</summary>
        string FullName { get; set; }
        /// <summary>企业简称</summary>
        string ShortName { get; set; }
        /// <summary>法人</summary>
        string LegalPerson { get; set; }
        /// <summary>负责人</summary>
        string Manager { get; set; }
        /// <summary>联系电话</summary>
        string Mobile { get; set; }
        /// <summary>邮箱</summary>
        string Email { get; set; }
        /// <summary>主页</summary>
        string MainPage { get; set; }
        /// <summary>所属省份</summary>
        string State { get; set; }
        /// <summary>所属地市</summary>
        string City { get; set; }
        /// <summary>所属区县</summary>
        string County { get; set; }
        /// <summary>地址</summary>
        string Address { get; set; }
        /// <summary>所属行业</summary>
        string Industry { get; set; }
        /// <summary>企业性质</summary>
        string Nature { get; set; }
        /// <summary>企业规模</summary>
        string Scale { get; set; }
        #endregion
    }
}
#endregion
#region "企业信息信息声明"
namespace Von.Web.Structs
{
    public class EnterpriseInfo : EnterpriseInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "企业信息")]
        public Guid ID { get; set; } = Guid.NewGuid();
        /// <summary>税号</summary>
        [Required]
        [LocalDisplay("税号", "企业信息")]
        public string Tax { get; set; } = "";
        /// <summary>企业全称</summary>
        [LocalDisplay("企业全称", "企业信息")]
        public string FullName { get; set; } = "";
        /// <summary>企业简称</summary>
        [LocalDisplay("企业简称", "企业信息")]
        public string ShortName { get; set; } = "";
        /// <summary>法人</summary>
        [LocalDisplay("法人", "企业信息")]
        public string LegalPerson { get; set; } = "";
        /// <summary>负责人</summary>
        [LocalDisplay("负责人", "企业信息")]
        public string Manager { get; set; } = "";
        /// <summary>联系电话</summary>
        [LocalDisplay("联系电话", "企业信息")]
        public string Mobile { get; set; } = "";
        /// <summary>邮箱</summary>
        [LocalDisplay("邮箱", "企业信息")]
        public string Email { get; set; } = "";
        /// <summary>主页</summary>
        [LocalDisplay("主页", "企业信息")]
        public string MainPage { get; set; } = "";
        /// <summary>所属省份</summary>
        [LocalDisplay("所属省份", "企业信息")]
        public string State { get; set; } = "";
        /// <summary>所属地市</summary>
        [LocalDisplay("所属地市", "企业信息")]
        public string City { get; set; } = "";
        /// <summary>所属区县</summary>
        [LocalDisplay("所属区县", "企业信息")]
        public string County { get; set; } = "";
        /// <summary>地址</summary>
        [LocalDisplay("地址", "企业信息")]
        public string Address { get; set; } = "";
        /// <summary>所属行业</summary>
        [LocalDisplay("所属行业", "企业信息")]
        public string Industry { get; set; } = "";
        /// <summary>企业性质</summary>
        [LocalDisplay("企业性质", "企业信息")]
        public string Nature { get; set; } = "";
        /// <summary>企业规模</summary>
        [LocalDisplay("企业规模", "企业信息")]
        public string Scale { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "企业信息扩展信息"
namespace Von.Web.Models
{
    public class EnterpriseModel : EnterpriseInfo
    {
        /// <summary>经营范围</summary>
        public string Scope { get; set; }
        /// <summary>简介</summary>
        public string Summary { get; set; }
        /// <summary>概况</summary>
        public string Survey { get; set; }
    }                                      
}                                           
#endregion 
#region "企业信息信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>企业信息 控制类</summary>
    /// <seealso cref="Von.Web.Models.EnterpriseInfo"/>
    public class EnterpriseTask
    {
        protected EnterpriseAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public EnterpriseTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<EnterpriseAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, EnterpriseInterface info)
        {
            info.ID = (Guid)reader["ID"];  //序号
            info.Tax = (string)reader["Tax"];  //税号
            info.FullName = (string)reader["FullName"];  //企业全称
            info.ShortName = (string)reader["ShortName"];  //企业简称
            info.LegalPerson = (string)reader["LegalPerson"];  //法人
            info.Manager = (string)reader["Manager"];  //负责人
            info.Mobile = (string)reader["Mobile"];  //联系电话
            info.Email = (string)reader["Email"];  //邮箱
            info.MainPage = (string)reader["MainPage"];  //主页
            info.State = (string)reader["State"];  //所属省份
            info.City = (string)reader["City"];  //所属地市
            info.County = (string)reader["County"];  //所属区县
            info.Address = (string)reader["Address"];  //地址
            info.Industry = (string)reader["Industry"];  //所属行业
            info.Nature = (string)reader["Nature"];  //企业性质
            info.Scale = (string)reader["Scale"];  //企业规模
            if (info is EnterpriseModel)
            {
                (info as EnterpriseModel).Scope = (string)reader["Scope"];  //经营范围
                (info as EnterpriseModel).Summary = (string)reader["Summary"];  //简介
                (info as EnterpriseModel).Survey = (string)reader["Survey"];  //概况
            }
        }
        /// <summary>检验Enterprise信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : EnterpriseInterface, new()
        {
            if (info.ID == Guid.Empty) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "序号");
            /// <summary>根据索引 IDX_TaxNo 提取信息</summary>
            if (string.IsNullOrEmpty(info.Tax)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "税号");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_Enterprise 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByEnterprise<T>(Guid ID) where T : EnterpriseInfo, new()
        {
            IDataReader reader = dbAccess.GetByEnterprise(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>得到经营范围信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="Scope">经营范围</param>
        public async Task<string> GetScope(int ID)
        {
            return dbAccess.GetScope(ID);
        }
        /// <summary>编辑经营范围信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="Scope">经营范围</param>
        public async Task<bool> SetScope(int ID, string Scope)
        {
            return dbAccess.SetScope(ID, Scope) > 0;
        }
        /// <summary>得到简介信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="Summary">简介</param>
        public async Task<string> GetSummary(int ID)
        {
            return dbAccess.GetSummary(ID);
        }
        /// <summary>编辑简介信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="Summary">简介</param>
        public async Task<bool> SetSummary(int ID, string Summary)
        {
            return dbAccess.SetSummary(ID, Summary) > 0;
        }
        /// <summary>得到概况信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="Survey">概况</param>
        public async Task<string> GetSurvey(int ID)
        {
            return dbAccess.GetSurvey(ID);
        }
        /// <summary>编辑概况信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="Survey">概况</param>
        public async Task<bool> SetSurvey(int ID, string Survey)
        {
            return dbAccess.SetSurvey(ID, Survey) > 0;
        }
        /// <summary>提取所有 企业信息 信息</summary>
        public async Task<List<T>> List<T>() where T : EnterpriseInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List();
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据索引 IDX_TaxNo 提取信息</summary>
        /// <param name="Tax">税号</param>
        public async Task<EnterpriseModel> GetByTaxNo(string Tax)
        {
            IDataReader reader = dbAccess.GetByTaxNo(Tax);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            EnterpriseModel info = new EnterpriseModel();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }

        /// <summary>自定义查询Enterprise信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : EnterpriseInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>添加Enterprise信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(EnterpriseModel info)
        {
            int effect = dbAccess.Add(info.ID, info.Tax, info.FullName, info.ShortName, info.LegalPerson, info.Manager, info.Mobile, info.Email, info.MainPage, info.State, info.City, info.County, info.Address, info.Industry, info.Nature, info.Scale, info.Scope, info.Summary, info.Survey);
            Runtime.Log.InfoFormat("添加企业信息{0}", info.ID);
            return effect > 0;
        }
        /// <summary>修改Enterprise信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(EnterpriseModel info)
        {
            int effect = dbAccess.Edit(info.ID, info.Tax, info.FullName, info.ShortName, info.LegalPerson, info.Manager, info.Mobile, info.Email, info.MainPage, info.State, info.City, info.County, info.Address, info.Industry, info.Nature, info.Scale, info.Scope, info.Summary, info.Survey);
            Runtime.Log.InfoFormat("修改企业信息{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_Enterprise删除Enterprise信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(Guid ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_Enterprise删除企业信息{0}", ID);
            return effect > 0;
        }
    }
}
#endregion
#region "企业信息信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="Von.Web.Models.EnterpriseInfo"/>
    /// <seealso cref="Von.Web.Operators.EnterpriseCtrl"/>
    public abstract class EnterpriseAccess : DBAccessBase
    {
        #region "Enterprise Abstract Methods"
        /// <summary>根据主键 PK_Enterprise 提取信息</summary>
        public abstract IDataReader GetByEnterprise(Guid ID);
        /// <summary>编辑经营范围信息</summary>
        ///<param name="int ID>序号</param>
        public abstract string GetScope(int ID);
        /// <summary>编辑经营范围信息</summary>
        public abstract int SetScope(int ID, string Scope);
        /// <summary>编辑简介信息</summary>
        ///<param name="int ID>序号</param>
        public abstract string GetSummary(int ID);
        /// <summary>编辑简介信息</summary>
        public abstract int SetSummary(int ID, string Summary);
        /// <summary>编辑概况信息</summary>
        ///<param name="int ID>序号</param>
        public abstract string GetSurvey(int ID);
        /// <summary>编辑概况信息</summary>
        public abstract int SetSurvey(int ID, string Survey);
        /// <summary>提取 企业信息 列表</summary>
        public abstract IDataReader List();
        /// <summary>查询 企业信息 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据索引 IDX_TaxNo 提取信息</summary>
        public abstract IDataReader GetByTaxNo(string Tax);
        /// <summary>添加Enterprise信息</summary>
        public abstract int Add(Guid ID, string Tax, string FullName, string ShortName, string LegalPerson, string Manager, string Mobile, string Email, string MainPage, string State, string City, string County, string Address, string Industry, string Nature, string Scale, string Scope, string Summary, string Survey);
        /// <summary>修改Enterprise信息</summary>
        public abstract int Edit(Guid ID, string Tax, string FullName, string ShortName, string LegalPerson, string Manager, string Mobile, string Email, string MainPage, string State, string City, string County, string Address, string Industry, string Nature, string Scale, string Scope, string Summary, string Survey);
        /// <summary>根据PK_Enterprise删除Enterprise信息</summary>
        public abstract int Del(Guid ID);
        #endregion
    }
}
#endregion
// 企业辅助(Von_EnterpriseSubsidiary)
#region "企业辅助接口声明"
namespace Von.Web.Apis
{
    public interface EnterpriseSubsidiaryInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>企业序号</summary>
        Guid EnterpriseIdx { get; set; }
        /// <summary>附属名称</summary>
        string SubsidiaryName { get; set; }
        /// <summary>辅助内容</summary>
        string Content { get; set; }
        #endregion
    }
}
#endregion
#region "企业辅助信息声明"
namespace Von.Web.Structs
{
    public class EnterpriseSubsidiaryInfo : EnterpriseSubsidiaryInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public EnterpriseSubsidiaryInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="EnterpriseIdx">企业序号</param>
        /// <param name="SubsidiaryName">附属名称</param>
        /// <param name="Content">辅助内容</param>
        public EnterpriseSubsidiaryInfo(int ID, Guid EnterpriseIdx, string SubsidiaryName, string Content)
        {
            this.ID = ID;
            this.EnterpriseIdx = EnterpriseIdx;
            this.SubsidiaryName = SubsidiaryName;
            this.Content = Content;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "企业辅助")]
        public int ID { get; set; } = 0;
        /// <summary>企业序号</summary>
        [Required]
        [LocalDisplay("企业序号", "企业辅助")]
        public Guid EnterpriseIdx { get; set; } = Guid.NewGuid();
        /// <summary>附属名称</summary>
        [LocalDisplay("附属名称", "企业辅助")]
        public string SubsidiaryName { get; set; } = "";
        /// <summary>辅助内容</summary>
        [LocalDisplay("辅助内容", "企业辅助")]
        public string Content { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "企业辅助信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>企业辅助 控制类</summary>
    /// <seealso cref="Von.Web.Models.EnterpriseSubsidiaryInfo"/>
    public class EnterpriseSubsidiaryTask
    {
        protected EnterpriseSubsidiaryAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public EnterpriseSubsidiaryTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<EnterpriseSubsidiaryAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, EnterpriseSubsidiaryInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.EnterpriseIdx = (Guid)reader["EnterpriseIdx"];  //企业序号
            info.SubsidiaryName = (string)reader["SubsidiaryName"];  //附属名称
            info.Content = (string)reader["Content"];  //辅助内容
        }
        /// <summary>检验EnterpriseSubsidiary信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : EnterpriseSubsidiaryInterface, new()
        {
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_EnterpriseSubsidiary 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByEnterpriseSubsidiary<T>(int ID) where T : EnterpriseSubsidiaryInfo, new()
        {
            IDataReader reader = dbAccess.GetByEnterpriseSubsidiary(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 企业辅助 信息</summary>
        public async Task<List<T>> List<T>() where T : EnterpriseSubsidiaryInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List();
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据索引 Idx_EnterpriseSubsidiary 提取信息</summary>
        /// <param name="EnterpriseIdx">企业序号</param>
        public async Task<List<T>> ListByIdx_EnterpriseSubsidiary<T>(Guid EnterpriseIdx) where T : EnterpriseSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByIdx_EnterpriseSubsidiary(EnterpriseIdx);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>自定义查询EnterpriseSubsidiary信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : EnterpriseSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据外键 辅助信息关联企业信息 提取信息</summary>
        public async Task<string> GetEnterpriseSubsidiaryValue(Guid EnterpriseIdx, string SubsidiaryName)
        {
            return dbAccess.GetEnterpriseSubsidiaryValue(EnterpriseIdx, SubsidiaryName);
        }
        /// <summary>保存EnterpriseSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Save<T>(T info) where T : EnterpriseSubsidiaryInfo, new()
        {
            if (info.ID == 0) return await Add(info);
            else return await Edit(info);
        }
        /// <summary>添加EnterpriseSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(EnterpriseSubsidiaryInfo info)
        {
            info.ID = dbAccess.Add(info.EnterpriseIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("添加企业辅助{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改EnterpriseSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(EnterpriseSubsidiaryInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.EnterpriseIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("修改企业辅助{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_EnterpriseSubsidiary删除EnterpriseSubsidiary信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_EnterpriseSubsidiary删除企业辅助{0}", ID);
            return effect > 0;
        }
        /// <summary>根据辅助信息关联企业信息删除EnterpriseSubsidiary信息</summary>
        ///<param name="EnterpriseIdx">企业序号</param>
        public async Task<bool> DelEnterprise(Guid EnterpriseIdx)
        {
            int effect = dbAccess.DelEnterprise(EnterpriseIdx);
            Runtime.Log.InfoFormat("根据辅助信息关联企业信息删除企业辅助{0}", EnterpriseIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "企业辅助信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="Von.Web.Models.EnterpriseSubsidiaryInfo"/>
    /// <seealso cref="Von.Web.Operators.EnterpriseSubsidiaryCtrl"/>
    public abstract class EnterpriseSubsidiaryAccess : DBAccessBase
    {
        #region "EnterpriseSubsidiary Abstract Methods"
        /// <summary>根据主键 PK_EnterpriseSubsidiary 提取信息</summary>
        public abstract IDataReader GetByEnterpriseSubsidiary(int ID);
        /// <summary>提取 企业辅助 列表</summary>
        public abstract IDataReader List();
        /// <summary>查询 企业辅助 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据索引 Idx_EnterpriseSubsidiary 提取信息</summary>
        public abstract IDataReader ListByIdx_EnterpriseSubsidiary(Guid EnterpriseIdx);
        /// <summary>根据属性名称直接提取企业属性内容</summary>
        public abstract string GetEnterpriseSubsidiaryValue(Guid EnterpriseIdx, string SubsidiaryName);
        /// <summary>添加EnterpriseSubsidiary信息</summary>
        public abstract int Add(Guid EnterpriseIdx, string SubsidiaryName, string Content);
        /// <summary>修改EnterpriseSubsidiary信息</summary>
        public abstract int Edit(int ID, Guid EnterpriseIdx, string SubsidiaryName, string Content);
        /// <summary>根据PK_EnterpriseSubsidiary删除EnterpriseSubsidiary信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据辅助信息关联企业信息删除EnterpriseSubsidiary信息</summary>
        public abstract int DelEnterprise(Guid EnterpriseIdx);
        #endregion
    }
}
#endregion
// 系统部门(Von_Department)
#region "系统部门接口声明"
namespace Von.Web.Apis
{
    public interface DepartmentInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>部门名称</summary>
        string Department { get; set; }
        /// <summary>所属企业</summary>
        Guid EnterpriseIdx { get; set; }
        /// <summary>上级序号</summary>
        int PID { get; set; }
        /// <summary>显示序号</summary>
        int DisplayOrder { get; set; }
        #endregion
    }
}
#endregion
#region "系统部门信息声明"
namespace Von.Web.Structs
{
    public class DepartmentInfo : DepartmentInterface, ITree<int>
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public DepartmentInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="Department">部门名称</param>
        /// <param name="EnterpriseIdx">所属企业</param>
        /// <param name="PID">上级序号</param>
        /// <param name="DisplayOrder">显示序号</param>
        public DepartmentInfo(int ID, string Department, Guid EnterpriseIdx, int PID, int DisplayOrder)
        {
            this.ID = ID;
            this.Department = Department;
            this.EnterpriseIdx = EnterpriseIdx;
            this.PID = PID;
            this.DisplayOrder = DisplayOrder;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "系统部门")]
        public int ID { get; set; } = 0;
        /// <summary>部门名称</summary>
        [LocalDisplay("部门名称", "系统部门")]
        public string Department { get; set; } = "";
        /// <summary>所属企业</summary>
        [Required]
        [LocalDisplay("所属企业", "系统部门")]
        public Guid EnterpriseIdx { get; set; } = Guid.NewGuid();
        /// <summary>上级序号</summary>
        [LocalDisplay("上级序号", "系统部门")]
        public int PID { get; set; } = 0;
        /// <summary>显示序号</summary>
        [LocalDisplay("显示序号", "系统部门")]
        public int DisplayOrder { get; set; } = 0;
        #endregion
    }
}
#endregion    
#region "系统部门扩展信息"
namespace Von.Web.Models
{
    public class DepartmentTreeGrid : DepartmentInfo, ITree<int>, ITreeChildren<DepartmentTreeGrid>
    {
        public List<DepartmentTreeGrid> children { get; set; }
    }
    public class DepartmentTree : DepartmentInfo, ITreeModel<int>, ITreeChildren<DepartmentTree>
    {
        /// <summary>节点的 id，它对于加载远程数据很重要</summary>
        public int id { get => ID; set => ID = value; }
        /// <summary>要显示的节点文本</summary>
        public string text { get => Department; set => Department = value; }
        /// <summary>，'open' 或 'closed'，默认是 'open'。当设置为 'closed' 时，该节点有子节点，并且将从远程站点加载它们</summary>
        public string state { get => (children == null || children.Count == 0) ? "open" : "closed"; }
        /// <summary>指示节点是否被选中</summary>
        public bool Checked { get; set; }
        /// <summary>给一个节点添加的自定义属性</summary>
        public string attributes { get; set; }
        public List<DepartmentTree> children { get; set; }
    }
}
#endregion  
#region "系统部门信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>系统部门 控制类</summary>
    /// <seealso cref="Von.Web.Models.DepartmentInfo"/>
    public class DepartmentTask
    {
        protected DepartmentAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public DepartmentTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<DepartmentAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, DepartmentInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.Department = (string)reader["Department"];  //部门名称
            info.EnterpriseIdx = (Guid)reader["EnterpriseIdx"];  //所属企业
            info.PID = (int)reader["PID"];  //上级序号
            info.DisplayOrder = (int)reader["DisplayOrder"];  //显示序号
        }
        /// <summary>检验Department信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : DepartmentInterface, new()
        {
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_Department 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByDepartment<T>(int ID) where T : DepartmentInfo, new()
        {
            IDataReader reader = dbAccess.GetByDepartment(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>
        /// 根据主键 PK_Department 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetDepartmentByName<T>(Guid EnterpriseIdx, string name) where T : DepartmentInfo, new()
        {
            IDataReader reader = dbAccess.GetDepartmentByName(EnterpriseIdx, name);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>自定义查询Department信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : DepartmentInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据外键 部门关联企业 提取信息</summary>
        public async Task<List<T>> ListByDEPARTMENT_REF_ENTERPRISE<T>(Guid EnterpriseIdx) where T : DepartmentInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByEnterprise(EnterpriseIdx);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>提取Tree结构信息</summary>
        public async Task<List<T>> TreeDepartment<T>(Guid EnterpriseIdx, int PID, bool hasChildren)where T : DepartmentInfo, ITreeChildren<T>, new()
        {
            List<T> tree = new List<T>();
            IDataReader reader = dbAccess.ListByPID(EnterpriseIdx, PID);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                tree.Add(info);
                if (hasChildren)
                    info.children = await TreeDepartment<T>(EnterpriseIdx, info.ID, hasChildren);
            }
            reader.Close();
            return tree;
        }
        /// <summary>保存Department信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Save<T>(T info) where T : DepartmentInfo, new()
        {
            if (info.ID == 0) return await Add(info);
            else return await Edit(info);
        }
        /// <summary>移动Department信息</summary>
        ///<param name="ID">信息键值</param>
        ///<param name="newOrder">新位置序号</param>
        ///<seealso>
        /// create procedure Von_Move_Department
        /// @ID int,
        /// @PID int,
        /// @NewOrder int
        /// as begin
        /// 	DECLARE @OldOrd int
        /// 	DECLARE @OldPID int
        /// 	SELECT @OldOrd=DisplayOrder,@OldPID=PID FROM Von_Department WHERE ID=@ID
        /// 	IF(@PID<>@OldPID)BEGIN  --层级移动，修改当前节点，更新原位置后续节点序号
        /// 	    SELECT @NewOrder=IsNull(MAX(DisplayOrder),0)+1 FROM Von_Department WHERE PID=@PID
        /// 		UPDATE Von_Department SET DisplayOrder=DisplayOrder-1 WHERE PID=@OldPID AND DisplayOrder>@OldOrd
        /// 	END ELSE IF(@OldOrd<@NewOrder)BEGIN --向上移动
        /// 		UPDATE Von_Department SET DisplayOrder=DisplayOrder-1 WHERE PID=@PID AND DisplayOrder>@OldOrd AND DisplayOrder<=@NewOrder
        /// 	END ELSE BEGIN  --向下移动
        /// 		UPDATE Von_Department SET DisplayOrder=DisplayOrder+1 WHERE PID=@PID AND DisplayOrder<@OldOrd AND DisplayOrder>=@NewOrder
        /// 	END
        /// 	UPDATE Von_Department SET DisplayOrder=@NewOrder,PID=@PID WHERE ID=@ID
        /// end
        /// go
        ///</seealso>
        public async Task<bool> Move(int ID, int PID, int DisplayOrder)
        {
            return dbAccess.Move(ID, PID, DisplayOrder) > 0;
        }
        /// <summary>添加Department信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(DepartmentInfo info)
        {
            info.ID = dbAccess.Add(info.Department, info.EnterpriseIdx, info.PID, info.DisplayOrder);
            Runtime.Log.InfoFormat("添加系统部门{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改Department信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(DepartmentInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.Department, info.EnterpriseIdx, info.PID, info.DisplayOrder);
            Runtime.Log.InfoFormat("修改系统部门{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_Department删除Department信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_Department删除系统部门{0}", ID);
            return effect > 0;
        }
        /// <summary>根据部门关联企业删除Department信息</summary>
        ///<param name="EnterpriseIdx">所属企业</param>
        public async Task<bool> DelEnterprise(Guid EnterpriseIdx)
        {
            int effect = dbAccess.DelEnterprise(EnterpriseIdx);
            Runtime.Log.InfoFormat("根据部门关联企业删除系统部门{0}", EnterpriseIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "系统部门信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="Von.Web.Models.DepartmentInfo"/>
    /// <seealso cref="Von.Web.Operators.DepartmentCtrl"/>
    public abstract class DepartmentAccess : DBAccessBase
    {
        #region "Department Abstract Methods"
        /// <summary>根据主键 PK_Department 提取信息</summary>
        public abstract IDataReader GetByDepartment(int ID);
        /// <summary>提取 系统部门 列表</summary>
        public abstract IDataReader ListByPID(Guid EnterpriseIdx, int PID);
        /// <summary>查询 系统部门 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据外键 部门关联企业 提取信息</summary>
        public abstract IDataReader ListByEnterprise(Guid EnterpriseIdx);
        /// <summary>移动一个节点显示位置</summary>
        public abstract int Move(int ID, int PID, int DisplayOrder);
        /// <summary>添加Department信息</summary>
        public abstract int Add(string Department, Guid EnterpriseIdx, int PID, int DisplayOrder);
        /// <summary>修改Department信息</summary>
        public abstract int Edit(int ID, string Department, Guid EnterpriseIdx, int PID, int DisplayOrder);
        /// <summary>根据PK_Department删除Department信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据部门关联企业删除Department信息</summary>
        public abstract int DelEnterprise(Guid EnterpriseIdx);
        /// <summary>根据部门关联企业删除Department信息</summary>
        public abstract IDataReader GetDepartmentByName(Guid EnterpriseIdx, string name);
        #endregion
    }
}
#endregion
// 企业内部门辅助(Von_DepartmentSubsidiary)
#region "企业内部门辅助接口声明"
namespace Von.Web.Apis
{
    public interface DepartmentSubsidiaryInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>部门序号</summary>
        int DepartmentIdx { get; set; }
        /// <summary>附属名称</summary>
        string SubsidiaryName { get; set; }
        /// <summary>辅助内容</summary>
        string Content { get; set; }
        #endregion
    }
}
#endregion
#region "企业内部门辅助信息声明"
namespace Von.Web.Structs
{
    public class DepartmentSubsidiaryInfo : DepartmentSubsidiaryInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public DepartmentSubsidiaryInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="DepartmentIdx">部门序号</param>
        /// <param name="SubsidiaryName">附属名称</param>
        /// <param name="Content">辅助内容</param>
        public DepartmentSubsidiaryInfo(int ID, int DepartmentIdx, string SubsidiaryName, string Content)
        {
            this.ID = ID;
            this.DepartmentIdx = DepartmentIdx;
            this.SubsidiaryName = SubsidiaryName;
            this.Content = Content;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "企业内部门辅助")]
        public int ID { get; set; } = 0;
        /// <summary>部门序号</summary>
        [Required]
        [LocalDisplay("部门序号", "企业内部门辅助")]
        public int DepartmentIdx { get; set; } = 0;
        /// <summary>附属名称</summary>
        [LocalDisplay("附属名称", "企业内部门辅助")]
        public string SubsidiaryName { get; set; } = "";
        /// <summary>辅助内容</summary>
        [LocalDisplay("辅助内容", "企业内部门辅助")]
        public string Content { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "企业内部门辅助信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>企业内部门辅助 控制类</summary>
    /// <seealso cref="Von.Web.Models.DepartmentSubsidiaryInfo"/>
    public class DepartmentSubsidiaryTask
    {
        protected DepartmentSubsidiaryAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public DepartmentSubsidiaryTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<DepartmentSubsidiaryAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, DepartmentSubsidiaryInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.DepartmentIdx = (int)reader["DepartmentIdx"];  //部门序号
            info.SubsidiaryName = (string)reader["SubsidiaryName"];  //附属名称
            info.Content = (string)reader["Content"];  //辅助内容
        }
        /// <summary>检验DepartmentSubsidiary信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : DepartmentSubsidiaryInterface, new()
        {
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_DepartmentSubsidiary 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<DepartmentSubsidiaryInfo> GetByDepartmentSubsidiary(int ID)
        {
            IDataReader reader = dbAccess.GetByDepartmentSubsidiary(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            DepartmentSubsidiaryInfo info = new DepartmentSubsidiaryInfo();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 企业内部门辅助 信息</summary>
        public async Task<List<T>> List<T>() where T : DepartmentSubsidiaryInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List();
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据索引 Idx_DepartmentSubsidiary 提取信息</summary>
        /// <param name="DepartmentIdx">部门序号</param>
        public async Task<List<T>> ListByIdx_DepartmentSubsidiary<T>(int DepartmentIdx) where T : DepartmentSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByIdx_DepartmentSubsidiary(DepartmentIdx);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>自定义查询DepartmentSubsidiary信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : DepartmentSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据外键 Reference_55 提取信息</summary>
        public async Task<string> GetDepartmentSubsidiaryValue(int DepartmentIdx, string SubsidiaryName)
        {
            return dbAccess.GetDepartmentSubsidiaryValue(DepartmentIdx, SubsidiaryName);
        }
        /// <summary>保存DepartmentSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Save<T>(T info) where T : DepartmentSubsidiaryInfo, new()
        {
            if (info.ID == 0) return await Add(info);
            else return await Edit(info);
        }
        /// <summary>添加DepartmentSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(DepartmentSubsidiaryInfo info)
        {
            info.ID = dbAccess.Add(info.DepartmentIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("添加企业内部门辅助{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改DepartmentSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(DepartmentSubsidiaryInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.DepartmentIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("修改企业内部门辅助{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_DepartmentSubsidiary删除DepartmentSubsidiary信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_DepartmentSubsidiary删除企业内部门辅助{0}", ID);
            return effect > 0;
        }
        /// <summary>根据Reference_55删除DepartmentSubsidiary信息</summary>
        ///<param name="DepartmentIdx">部门序号</param>
        public async Task<bool> DelDepartment(int DepartmentIdx)
        {
            int effect = dbAccess.DelDepartment(DepartmentIdx);
            Runtime.Log.InfoFormat("根据Reference_55删除企业内部门辅助{0}", DepartmentIdx);
            return effect > 0;
        }

        public async Task<DepartmentSubsidiaryInfo> GetByDepartment(int ID, string PropertyName)
        {
            IDataReader reader = dbAccess.GetByDepartmentSubsidiary(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            DepartmentSubsidiaryInfo info = new DepartmentSubsidiaryInfo();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
    }
}
#endregion
#region "企业内部门辅助信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="Von.Web.Models.DepartmentSubsidiaryInfo"/>
    /// <seealso cref="Von.Web.Operators.DepartmentSubsidiaryCtrl"/>
    public abstract class DepartmentSubsidiaryAccess : DBAccessBase
    {
        #region "DepartmentSubsidiary Abstract Methods"
        /// <summary>根据主键 PK_DepartmentSubsidiary 提取信息</summary>
        public abstract IDataReader GetByDepartmentSubsidiary(int ID);
        /// <summary>提取 企业内部门辅助 列表</summary>
        public abstract IDataReader List();
        /// <summary>查询 企业内部门辅助 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据索引 Idx_DepartmentSubsidiary 提取信息</summary>
        public abstract IDataReader ListByIdx_DepartmentSubsidiary(int DepartmentIdx);
        /// <summary>根据外键 Reference_55 提取信息</summary>
        public abstract string GetDepartmentSubsidiaryValue(int DepartmentIdx, string SubsidiaryName);
        /// <summary>添加DepartmentSubsidiary信息</summary>
        public abstract int Add(int DepartmentIdx, string SubsidiaryName, string Content);
        /// <summary>修改DepartmentSubsidiary信息</summary>
        public abstract int Edit(int ID, int DepartmentIdx, string SubsidiaryName, string Content);
        /// <summary>根据PK_DepartmentSubsidiary删除DepartmentSubsidiary信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据Reference_55删除DepartmentSubsidiary信息</summary>
        public abstract int DelDepartment(int DepartmentIdx);
        #endregion
    }
}
#endregion
#endregion
#region 综合查询
namespace Von.Web
{
    namespace Models
    {
        public class SynthStateFlowModel
        {
            /// <summary>项目序号</summary>
            public Guid ItemID { get; set; }
            /// <summary>流程名称</summary>
            public string FlowName { get; set; }
            /// <summary>进入状态</summary>
            public string InStatus { get; set; }
            /// <summary>操作名称</summary>
            public string MethodName { get; set; }
            /// <summary>按钮样式</summary>
            public string Style { get; set; }
            /// <summary>操作后状态</summary>
            public string OutStatus { get; set; }
            /// <summary>处理参数</summary>
            public string OutData { get; set; }
        }
    }
    namespace Tasks
    {
        public class SynthesizeTask
        {
            protected SynthesizeAccess dbAccess = null;
            /// <summary>含数据库事务的构造函数</summary>
            public SynthesizeTask(DbTransaction DBTrans = null)
            {
                dbAccess = Statement.App.GetAccess<SynthesizeAccess>(DBTrans);
            }
            /// <summary>提取所有 行政区划 信息</summary>
            public async Task<List<SynthStateFlowModel>> ListFlowItemsByFlowKind(string Kind, string FlowName = null)
            {
                List<SynthStateFlowModel> list = new List<SynthStateFlowModel>();
                IDataReader reader = dbAccess.ListFlowItemsByFlowKind(Kind, FlowName);
                while (reader.Read())
                {
                    SynthStateFlowModel info = new SynthStateFlowModel();
                    info.ItemID = (Guid)reader["ItemID"];  //流程名称
                    info.FlowName = (string)reader["FlowName"];  //流程名称
                    info.InStatus = (string)reader["InStatus"];  //进入状态
                    info.MethodName = (string)reader["MethodName"];  //操作名称
                    info.Style = (string)reader["Style"];  //按钮样式
                    info.OutStatus = (string)reader["OutStatus"];  //操作后状态
                    info.OutData = (string)reader["OutData"];  //处理参数
                    list.Add(info);
                }
                reader.Close();
                return list;
            }
        }
    }
    namespace Datas
    {
        public abstract class SynthesizeAccess : DBAccessBase
        {
            #region "StateFlow 综合查询"
            /// <summary>根据主键 审批流 提取信息</summary>
            public abstract IDataReader ListFlowItemsByFlowKind(string Kind, string FlowName = null);
            #endregion

        }
    }
}
#endregion
#region 维度管理
// 维度(Von_Dimension)
#region "维度接口声明"
namespace Von.Web.Apis
{
    public interface DimensionInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        Guid ID { get; set; }
        /// <summary>维度名称</summary>
        string DimName { get; set; }
        /// <summary>编码规则</summary>
        string CodeRule { get; set; }
        #endregion
    }
}
#endregion
#region "维度信息声明"
namespace Von.Web.Structs
{
    public class DimensionInfo : DimensionInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public DimensionInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="DimName">维度名称</param>
        /// <param name="CodeRule">编码规则</param>
        public DimensionInfo(Guid ID, string DimName, string CodeRule)
        {
            this.ID = ID;
            this.DimName = DimName;
            this.CodeRule = CodeRule;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "维度")]
        public Guid ID { get; set; } = Guid.NewGuid();
        /// <summary>维度名称</summary>
        [LocalDisplay("维度名称", "维度")]
        public string DimName { get; set; } = "";
        /// <summary>编码规则</summary>
        [LocalDisplay("编码规则", "维度")]
        public string CodeRule { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "维度扩展信息"
namespace Von.Web.Models
{
    public class DimensionModel : DimensionInfo
    {
        /// <summary>维度说明</summary>
        [LocalDisplay("维度说明", "维度")]
        public string DimNote { get; set; }
    }
}
#endregion 
#region "维度信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>维度 控制类</summary>
    /// <seealso cref="ZTY.OA.Models.DimensionInfo"/>
    public class DimensionTask
    {
        protected DimensionAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public DimensionTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<DimensionAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, DimensionInterface info)
        {
            info.ID = (Guid)reader["ID"];  //序号
            info.DimName = (string)reader["DimName"];  //维度名称
            info.CodeRule = (string)reader["CodeRule"];  //编码规则
            if (info is DimensionModel)
            {
                (info as DimensionModel).DimNote = (string)reader["DimNote"];  //维度说明
            }
        }
        /// <summary>检验Dimension信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : DimensionInterface, new()
        {
            if (info.ID == Guid.Empty) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "序号");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_DIM 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<DimensionModel> GetByDIM(Guid ID)
        {
            IDataReader reader = dbAccess.GetByDIM(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            DimensionModel info = new DimensionModel();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>得到维度说明信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="DimNote">维度说明</param>
        public async Task<string> GetDimNote(int ID)
        {
            return dbAccess.GetDimNote(ID);
        }
        /// <summary>编辑维度说明信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="DimNote">维度说明</param>
        public async Task<bool> SetDimNote(int ID, string DimNote)
        {
            return dbAccess.SetDimNote(ID, DimNote) > 0;
        }
        /// <summary>提取所有 维度 信息</summary>
        public async Task<List<T>> List<T>() where T : DimensionInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List();
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : DimensionInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>添加Dimension信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(DimensionModel info)
        {
            int effect = dbAccess.Add(info.ID, info.DimName, info.CodeRule, info.DimNote);
            Runtime.Log.InfoFormat("添加维度{0}", info.ID);
            return effect > 0;
        }
        /// <summary>修改Dimension信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(DimensionModel info)
        {
            int effect = dbAccess.Edit(info.ID, info.DimName, info.CodeRule, info.DimNote);
            Runtime.Log.InfoFormat("修改维度{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_DIM删除Dimension信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(Guid ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_DIM删除维度{0}", ID);
            return effect > 0;
        }
    }
}
#endregion
#region "维度信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="ZTY.OA.Models.DimensionInfo"/>
    /// <seealso cref="ZTY.OA.Operators.DimensionCtrl"/>
    public abstract class DimensionAccess : DBAccessBase
    {
        #region "Dimension Abstract Methods"
        /// <summary>根据主键 PK_DIM 提取信息</summary>
        ///<param name="ID">序号</param>
        public abstract IDataReader GetByDIM(Guid ID);
        /// <summary>编辑维度说明信息</summary>
        ///<param name="ID">序号</param>
        ///<param name="DimNote">维度说明</param>
        public abstract string GetDimNote(int ID);
        /// <summary>编辑维度说明信息</summary>
        public abstract int SetDimNote(int ID, string DimNote);
        /// <summary>提取 维度 列表</summary>
        public abstract IDataReader List();
        /// <summary>查询 维度 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>添加Dimension信息</summary>
        public abstract int Add(Guid ID, string DimName, string CodeRule, string DimNote);
        /// <summary>修改Dimension信息</summary>
        public abstract int Edit(Guid ID, string DimName, string CodeRule, string DimNote);
        /// <summary>根据PK_DIM删除Dimension信息</summary>
        public abstract int Del(Guid ID);
        #endregion
    }
}
#endregion
// 维度项目(Von_DimItem)
#region "维度项目接口声明"
namespace Von.Web.Apis
{
    public interface DimItemInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        Guid ID { get; set; }
        /// <summary>所属维度</summary>
        Guid DimIdx { get; set; }
        /// <summary>项目名称</summary>
        string ItemName { get; set; }
        /// <summary>父级序号</summary>
        Guid PID { get; set; }
        /// <summary>显示序号</summary>
        int DisplayOrder { get; set; }
        #endregion
    }
}
#endregion
#region "维度项目信息声明"
namespace Von.Web.Structs
{
    public class DimItemInfo : DimItemInterface, ITree<Guid>
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public DimItemInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="DimIdx">所属维度</param>
        /// <param name="ItemName">项目名称</param>
        /// <param name="PID">父级序号</param>
        /// <param name="DisplayOrder">显示序号</param>
        public DimItemInfo(Guid ID, Guid DimIdx, string ItemName, Guid PID, int DisplayOrder)
        {
            this.ID = ID;
            this.DimIdx = DimIdx;
            this.ItemName = ItemName;
            this.PID = PID;
            this.DisplayOrder = DisplayOrder;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "维度项目")]
        public Guid ID { get; set; } = Guid.NewGuid();
        /// <summary>所属维度</summary>
        [Required]
        [LocalDisplay("所属维度", "维度项目")]
        public Guid DimIdx { get; set; } = Guid.NewGuid();
        /// <summary>项目名称</summary>
        [LocalDisplay("项目名称", "维度项目")]
        public string ItemName { get; set; } = "";
        /// <summary>父级序号</summary>
        [Required]
        [LocalDisplay("父级序号", "维度项目")]
        public Guid PID { get; set; } = Guid.NewGuid();
        /// <summary>显示序号</summary>
        [Required]
        [LocalDisplay("显示序号", "维度项目")]
        public int DisplayOrder { get; set; } = 0;
        #endregion
    }
}
#endregion    
#region "维度项目扩展信息"
namespace Von.Web.Models
{
    public class DimItemTree : DimItemInfo
    {
        /// <summary>节点的 id，它对于加载远程数据很重要</summary>
        //public Guid id { get => ID; set => ID = value; }
        ///// <summary>要显示的节点文本</summary>
        //public string text { get => ItemName; set => ItemName = value; }
        /// <summary>，'open' 或 'closed'，默认是 'open'。当设置为 'closed' 时，该节点有子节点，并且将从远程站点加载它们</summary>
        public string state { get => (children == null || children.Count == 0) ? "open" : "closed"; }
        /// <summary>指示节点是否被选中</summary>
        public bool Checked { get; set; }
        /// <summary>给一个节点添加的自定义属性</summary>
        public string attributes { get; set; }
        public List<DimItemTree> children { get; set; }
    }
}
#endregion  
#region "维度项目信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>维度项目 控制类</summary>
    /// <seealso cref="ZTY.OA.Models.DimItemInfo"/>
    public class DimItemTask
    {
        protected DimItemAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public DimItemTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<DimItemAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, DimItemInterface info)
        {
            info.ID = (Guid)reader["ID"];  //序号
            info.DimIdx = (Guid)reader["DimIdx"];  //所属维度
            info.ItemName = (string)reader["ItemName"];  //项目名称
            info.PID = (Guid)reader["PID"];  //父级序号
            info.DisplayOrder = (int)reader["DisplayOrder"];  //显示序号
        }
        /// <summary>检验DimItem信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : DimItemInterface, new()
        {
            if (info.ID == Guid.Empty) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "序号");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_DimItem 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByDimItem<T>(Guid ID) where T : DimItemInfo, new()
        {
            IDataReader reader = dbAccess.GetByDimItem(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 维度项目 信息</summary>
        public async Task<List<T>> List<T>() where T : DimItemInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List();
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据索引 IDX_DimItem 提取信息</summary>
        /// <param name="DimIdx">所属维度</param>
        /// <param name="PID">父级序号</param>
        /// <param name="DisplayOrder">显示序号</param>
        public async Task<List<T>> ListByDimItem<T>(Guid DimIdx, Guid PID) where T : DimItemInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByDimItem(DimIdx, PID);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>自定义查询DimItem信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : DimItemInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据外键 FK_OA_ITEM_REF_DIMENSION 提取信息</summary>
        public async Task<List<T>> ListByOA_ITEM_REF_DIMENSION<T>(Guid DimIdx) where T : DimItemInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByOA_ITEM_REF_DIMENSION(DimIdx);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>移动DimItem信息</summary>
        ///<param name="ID">信息键值</param>
        ///<param name="newOrder">新位置序号</param>
        ///<seealso>
        /// create procedure OA_Move_DimItem
        /// @ID uniqueidentifier,
        /// @PID uniqueidentifier,
        /// @NewOrder int
        /// as begin
        /// 	DECLARE @OldOrd int
        /// 	DECLARE @OldPID uniqueidentifier
        /// 	SELECT @OldOrd=DisplayOrder,@OldPID=PID FROM OA_DimItem WHERE ID=@ID
        /// 	IF(@PID<>@OldPID)BEGIN  --层级移动，修改当前节点，更新原位置后续节点序号
        /// 	    SELECT @NewOrder=IsNull(MAX(DisplayOrder),0)+1 FROM OA_DimItem WHERE PID=@PID
        /// 		UPDATE OA_DimItem SET DisplayOrder=DisplayOrder-1 WHERE PID=@OldPID AND DisplayOrder>@OldOrd
        /// 	END ELSE IF(@OldOrd<@NewOrder)BEGIN --向上移动
        /// 		UPDATE OA_DimItem SET DisplayOrder=DisplayOrder-1 WHERE PID=@PID AND DisplayOrder>@OldOrd AND DisplayOrder<=@NewOrder
        /// 	END ELSE BEGIN  --向下移动
        /// 		UPDATE OA_DimItem SET DisplayOrder=DisplayOrder+1 WHERE PID=@PID AND DisplayOrder<@OldOrd AND DisplayOrder>=@NewOrder
        /// 	END
        /// 	UPDATE OA_DimItem SET DisplayOrder=@NewOrder,PID=@PID WHERE ID=@ID
        /// end
        /// go
        ///</seealso>
        public async Task<bool> Move(Guid ID, Guid PID, int DisplayOrder)
        {
            return dbAccess.Move(ID, PID, DisplayOrder) > 0;
        }
        /// <summary>添加DimItem信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(DimItemInfo info)
        {
            int effect = dbAccess.Add(info.ID, info.DimIdx, info.ItemName, info.PID, info.DisplayOrder);
            Runtime.Log.InfoFormat("添加维度项目{0}", info.ID);
            return effect > 0;
        }
        /// <summary>修改DimItem信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(DimItemInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.DimIdx, info.ItemName, info.PID, info.DisplayOrder);
            Runtime.Log.InfoFormat("修改维度项目{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_DimItem删除DimItem信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(Guid ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_DimItem删除维度项目{0}", ID);
            return effect > 0;
        }
        /// <summary>根据FK_OA_ITEM_REF_DIMENSION删除DimItem信息</summary>
        ///<param name="DimIdx">所属维度</param>
        public async Task<bool> DelDim(Guid DimIdx)
        {
            int effect = dbAccess.DelDim(DimIdx);
            Runtime.Log.InfoFormat("根据FK_OA_ITEM_REF_DIMENSION删除维度项目{0}", DimIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "维度项目信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="ZTY.OA.Models.DimItemInfo"/>
    /// <seealso cref="ZTY.OA.Operators.DimItemCtrl"/>
    public abstract class DimItemAccess : DBAccessBase
    {
        #region "DimItem Abstract Methods"
        /// <summary>根据主键 PK_DimItem 提取信息</summary>
        ///<param name="ID">序号</param>
        public abstract IDataReader GetByDimItem(Guid ID);
        /// <summary>提取 维度项目 列表</summary>
        public abstract IDataReader List();
        /// <summary>查询 维度项目 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据主键 IDX_DimItem 提取信息</summary>
        public abstract IDataReader ListByDimItem(Guid DimIdx, Guid PID);
        /// <summary>根据外键 FK_OA_ITEM_REF_DIMENSION 提取信息</summary>
        public abstract IDataReader ListByOA_ITEM_REF_DIMENSION(Guid DimIdx);
        /// <summary>移动DimItem显示顺序</summary>
        public abstract int Move(Guid ID, Guid PID, int NewOrder);
        /// <summary>添加DimItem信息</summary>
        public abstract int Add(Guid ID, Guid DimIdx, string ItemName, Guid PID, int DisplayOrder);
        /// <summary>修改DimItem信息</summary>
        public abstract int Edit(Guid ID, Guid DimIdx, string ItemName, Guid PID, int DisplayOrder);
        /// <summary>根据PK_DimItem删除DimItem信息</summary>
        public abstract int Del(Guid ID);
        /// <summary>根据FK_OA_ITEM_REF_DIMENSION删除DimItem信息</summary>
        public abstract int DelDim(Guid DimIdx);
        #endregion
    }
}
#endregion
// 维度项目辅助(Von_DimItemSubsidiary)
#region "维度项目辅助接口声明"
namespace Von.Web.Apis
{
    public interface DimItemSubsidiaryInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>维度</summary>
        Guid ItemIdx { get; set; }
        /// <summary>附属名称</summary>
        string SubsidiaryName { get; set; }
        /// <summary>辅助内容</summary>
        string Content { get; set; }
        #endregion
    }
}
#endregion
#region "维度项目辅助信息声明"
namespace Von.Web.Structs
{
    public class DimItemSubsidiaryInfo : DimItemSubsidiaryInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public DimItemSubsidiaryInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="ItemIdx">维度</param>
        /// <param name="SubsidiaryName">附属名称</param>
        /// <param name="Content">辅助内容</param>
        public DimItemSubsidiaryInfo(int ID, Guid ItemIdx, string SubsidiaryName, string Content)
        {
            this.ID = ID;
            this.ItemIdx = ItemIdx;
            this.SubsidiaryName = SubsidiaryName;
            this.Content = Content;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "维度项目辅助")]
        public int ID { get; set; } = 0;
        /// <summary>维度</summary>
        [Required]
        [LocalDisplay("维度", "维度项目辅助")]
        public Guid ItemIdx { get; set; } = Guid.NewGuid();
        /// <summary>附属名称</summary>
        [Required]
        [LocalDisplay("附属名称", "维度项目辅助")]
        public string SubsidiaryName { get; set; } = "";
        /// <summary>辅助内容</summary>
        [LocalDisplay("辅助内容", "维度项目辅助")]
        public string Content { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "维度项目辅助信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>维度项目辅助 控制类</summary>
    /// <seealso cref="ZTY.OA.Models.DimItemSubsidiaryInfo"/>
    public class DimItemSubsidiaryTask
    {
        protected DimItemSubsidiaryAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public DimItemSubsidiaryTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<DimItemSubsidiaryAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, DimItemSubsidiaryInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.ItemIdx = (Guid)reader["ItemIdx"];  //维度
            info.SubsidiaryName = (string)reader["SubsidiaryName"];  //附属名称
            info.Content = (string)reader["Content"];  //辅助内容
        }
        /// <summary>检验DimItemSubsidiary信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : DimItemSubsidiaryInterface, new()
        {
            /// <summary>根据索引 IDX_DimItemSubsidiary 提取信息</summary>
            if (info.ItemIdx == Guid.Empty) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "维度");
            /// <summary>根据索引 IDX_DimItemSubsidiary 提取信息</summary>
            if (string.IsNullOrEmpty(info.SubsidiaryName)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "附属名称");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_DimItemSubsidiary 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<DimItemSubsidiaryInfo> GetByDimItemSubsidiary(int ID)
        {
            IDataReader reader = dbAccess.GetByDimItemSubsidiary(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            DimItemSubsidiaryInfo info = new DimItemSubsidiaryInfo();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 维度项目辅助 信息</summary>
        public async Task<List<T>> List<T>() where T : DimItemSubsidiaryInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List();
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据索引 IDX_DimItemSubsidiary 提取信息</summary>
        /// <param name="ItemIdx">维度</param>
        /// <param name="SubsidiaryName">附属名称</param>
        public async Task<DimItemSubsidiaryInfo> GetByDimItemSubsidiary(Guid ItemIdx, string SubsidiaryName)
        {
            IDataReader reader = dbAccess.GetByDimItemSubsidiary(ItemIdx, SubsidiaryName);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            DimItemSubsidiaryInfo info = new DimItemSubsidiaryInfo();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }

        /// <summary>自定义查询DimItemSubsidiary信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : DimItemSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据外键 FK_OA_ITEMSUBSIDIARY_REF_DIMITEM 提取信息</summary>
        public async Task<List<T>> ListByOA_ITEMSUBSIDIARY_REF_DIMITEM<T>(Guid ItemIdx) where T : DimItemSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByOA_ITEMSUBSIDIARY_REF_DIMITEM(ItemIdx);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>保存DimItemSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Save<T>(T info) where T : DimItemSubsidiaryInfo, new()
        {
            if (info.ID == 0) return await Add(info);
            else return await Edit(info);
        }
        /// <summary>添加DimItemSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(DimItemSubsidiaryInfo info)
        {
            info.ID = dbAccess.Add(info.ItemIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("添加维度项目辅助{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改DimItemSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(DimItemSubsidiaryInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.ItemIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("修改维度项目辅助{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_DimItemSubsidiary删除DimItemSubsidiary信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_DimItemSubsidiary删除维度项目辅助{0}", ID);
            return effect > 0;
        }
        /// <summary>根据FK_OA_ITEMSUBSIDIARY_REF_DIMITEM删除DimItemSubsidiary信息</summary>
        ///<param name="ItemIdx">维度</param>
        public async Task<bool> DelItem(Guid ItemIdx)
        {
            int effect = dbAccess.DelItem(ItemIdx);
            Runtime.Log.InfoFormat("根据FK_OA_ITEMSUBSIDIARY_REF_DIMITEM删除维度项目辅助{0}", ItemIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "维度项目辅助信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="ZTY.OA.Models.DimItemSubsidiaryInfo"/>
    /// <seealso cref="ZTY.OA.Operators.DimItemSubsidiaryCtrl"/>
    public abstract class DimItemSubsidiaryAccess : DBAccessBase
    {
        #region "DimItemSubsidiary Abstract Methods"
        /// <summary>根据主键 PK_DimItemSubsidiary 提取信息</summary>
        ///<param name="ID">序号</param>
        public abstract IDataReader GetByDimItemSubsidiary(int ID);
        /// <summary>提取 维度项目辅助 列表</summary>
        public abstract IDataReader List();
        /// <summary>查询 维度项目辅助 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据主键 IDX_DimItemSubsidiary 提取信息</summary>
        public abstract IDataReader GetByDimItemSubsidiary(Guid ItemIdx, string SubsidiaryName);
        /// <summary>根据外键 FK_OA_ITEMSUBSIDIARY_REF_DIMITEM 提取信息</summary>
        public abstract IDataReader ListByOA_ITEMSUBSIDIARY_REF_DIMITEM(Guid ItemIdx);
        /// <summary>添加DimItemSubsidiary信息</summary>
        public abstract int Add(Guid ItemIdx, string SubsidiaryName, string Content);
        /// <summary>修改DimItemSubsidiary信息</summary>
        public abstract int Edit(int ID, Guid ItemIdx, string SubsidiaryName, string Content);
        /// <summary>根据PK_DimItemSubsidiary删除DimItemSubsidiary信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据FK_OA_ITEMSUBSIDIARY_REF_DIMITEM删除DimItemSubsidiary信息</summary>
        public abstract int DelItem(Guid ItemIdx);
        #endregion
    }
}
#endregion
// 级联项目(Von_DimHierarchy)
#region "级联项目接口声明"
namespace Von.Web.Apis
{
    public interface DimHierarchyInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>所属维度</summary>
        Guid DimIdx { get; set; }
        /// <summary>项目名称</summary>
        string ItemName { get; set; }
        /// <summary>父序号</summary>
        int PID { get; set; }
        /// <summary>显示序号</summary>
        int DisplayOrder { get; set; }
        #endregion
    }
}
#endregion
#region "级联项目信息声明"
namespace Von.Web.Structs
{
    public class DimHierarchyInfo : DimHierarchyInterface, ITree<int>
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public DimHierarchyInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="DimIdx">所属维度</param>
        /// <param name="ItemName">项目名称</param>
        /// <param name="PID">父序号</param>
        /// <param name="DisplayOrder">显示序号</param>
        public DimHierarchyInfo(int ID, Guid DimIdx, string ItemName, int PID, int DisplayOrder)
        {
            this.ID = ID;
            this.DimIdx = DimIdx;
            this.ItemName = ItemName;
            this.PID = PID;
            this.DisplayOrder = DisplayOrder;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "级联项目")]
        public int ID { get; set; } = 0;
        /// <summary>所属维度</summary>
        [Required]
        [LocalDisplay("所属维度", "级联项目")]
        public Guid DimIdx { get; set; } = Guid.NewGuid();
        /// <summary>项目名称</summary>
        [LocalDisplay("项目名称", "级联项目")]
        public string ItemName { get; set; } = "";
        /// <summary>父序号</summary>
        [LocalDisplay("父序号", "级联项目")]
        public int PID { get; set; } = 0;
        /// <summary>显示序号</summary>
        [LocalDisplay("显示序号", "级联项目")]
        public int DisplayOrder { get; set; } = 0;
        #endregion
    }
}
#endregion    
#region "级联项目扩展信息"
namespace Von.Web.Models
{
    public class DimHierarchyTree : DimHierarchyInfo
    {
        /// <summary>，'open' 或 'closed'，默认是 'open'。当设置为 'closed' 时，该节点有子节点，并且将从远程站点加载它们</summary>
        public string state { get => (children == null || children.Count == 0) ? "open" : "closed"; }
        /// <summary>指示节点是否被选中</summary>
        public bool Checked { get; set; }
        /// <summary>给一个节点添加的自定义属性</summary>
        public string attributes { get; set; }
        public List<DimHierarchyTree> children { get; set; }
    }
}
#endregion  
#region "级联项目信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>级联项目 控制类</summary>
    /// <seealso cref="ZTY.OA.Models.DimHierarchyInfo"/>
    public class DimHierarchyTask
    {
        protected DimHierarchyAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public DimHierarchyTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<DimHierarchyAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, DimHierarchyInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.DimIdx = (Guid)reader["DimIdx"];  //所属维度
            info.ItemName = (string)reader["ItemName"];  //项目名称
            info.PID = (int)reader["PID"];  //父序号
            info.DisplayOrder = (int)reader["DisplayOrder"];  //显示序号
        }
        /// <summary>检验DimHierarchy信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : DimHierarchyInterface, new()
        {
            /// <summary>根据索引 IDX_DimHierarchy 提取信息</summary>
            if (info.DimIdx == Guid.Empty) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "所属维度");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_DimHierarchy 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByDimHierarchy<T>(int ID) where T : DimHierarchyInfo, new()
        {
            IDataReader reader = dbAccess.GetByDimHierarchy(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 级联项目 信息</summary>
        public async Task<List<T>> List<T>(Guid DimIdx, int PID) where T : DimHierarchyInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List(DimIdx, PID);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>保存DimHierarchy信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Save<T>(T info) where T : DimHierarchyInfo, new()
        {
            if (info.ID == 0) return await Add(info);
            else return await Edit(info);
        }
        /// <summary>移动DimHierarchy信息</summary>
        ///<param name="ID">信息键值</param>
        ///<param name="newOrder">新位置序号</param>
        ///<seealso>
        /// create procedure OA_Move_DimHierarchy
        /// @ID int,
        /// @PID int,
        /// @NewOrder int
        /// as begin
        /// 	DECLARE @OldOrd int
        /// 	DECLARE @OldPID int
        /// 	SELECT @OldOrd=DisplayOrder,@OldPID=PID FROM OA_DimHierarchy WHERE ID=@ID
        /// 	IF(@PID<>@OldPID)BEGIN  --层级移动，修改当前节点，更新原位置后续节点序号
        /// 	    SELECT @NewOrder=IsNull(MAX(DisplayOrder),0)+1 FROM OA_DimHierarchy WHERE PID=@PID
        /// 		UPDATE OA_DimHierarchy SET DisplayOrder=DisplayOrder-1 WHERE PID=@OldPID AND DisplayOrder>@OldOrd
        /// 	END ELSE IF(@OldOrd<@NewOrder)BEGIN --向上移动
        /// 		UPDATE OA_DimHierarchy SET DisplayOrder=DisplayOrder-1 WHERE PID=@PID AND DisplayOrder>@OldOrd AND DisplayOrder<=@NewOrder
        /// 	END ELSE BEGIN  --向下移动
        /// 		UPDATE OA_DimHierarchy SET DisplayOrder=DisplayOrder+1 WHERE PID=@PID AND DisplayOrder<@OldOrd AND DisplayOrder>=@NewOrder
        /// 	END
        /// 	UPDATE OA_DimHierarchy SET DisplayOrder=@NewOrder,PID=@PID WHERE ID=@ID
        /// end
        /// go
        ///</seealso>
        public async Task<bool> Move(int ID, int PID, int DisplayOrder)
        {
            return dbAccess.Move(ID, PID, DisplayOrder) > 0;
        }
        /// <summary>添加DimHierarchy信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(DimHierarchyInfo info)
        {
            info.ID = dbAccess.Add(info.DimIdx, info.ItemName, info.PID, info.DisplayOrder);
            Runtime.Log.InfoFormat("添加级联项目{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改DimHierarchy信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(DimHierarchyInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.DimIdx, info.ItemName, info.PID, info.DisplayOrder);
            Runtime.Log.InfoFormat("修改级联项目{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_DimHierarchy删除DimHierarchy信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_DimHierarchy删除级联项目{0}", ID);
            return effect > 0;
        }
        /// <summary>根据FK_OA_HIERARCHY_REF_DIM删除DimHierarchy信息</summary>
        ///<param name="DimIdx">所属维度</param>
        public async Task<bool> DelDim(Guid DimIdx)
        {
            int effect = dbAccess.DelDim(DimIdx);
            Runtime.Log.InfoFormat("根据FK_OA_HIERARCHY_REF_DIM删除级联项目{0}", DimIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "级联项目信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="ZTY.OA.Models.DimHierarchyInfo"/>
    /// <seealso cref="ZTY.OA.Operators.DimHierarchyCtrl"/>
    public abstract class DimHierarchyAccess : DBAccessBase
    {
        #region "DimHierarchy Abstract Methods"
        /// <summary>根据主键 PK_DimHierarchy 提取信息</summary>
        ///<param name="ID">序号</param>
        public abstract IDataReader GetByDimHierarchy(int ID);
        /// <summary>提取 级联项目 列表</summary>
        public abstract IDataReader List(Guid DimIdx, int PID);
        /// <summary>查询 级联项目 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据主键 IDX_DimHierarchy 提取信息</summary>
        public abstract IDataReader ListByDimHierarchy(Guid DimIdx);
        /// <summary>根据外键 FK_OA_HIERARCHY_REF_DIM 提取信息</summary>
        public abstract IDataReader ListByOA_HIERARCHY_REF_DIM(Guid DimIdx);
        /// <summary>移动DimHierarchy显示顺序</summary>
        public abstract int Move(int ID, int PID, int NewOrder);
        /// <summary>添加DimHierarchy信息</summary>
        public abstract int Add(Guid DimIdx, string ItemName, int PID, int DisplayOrder);
        /// <summary>修改DimHierarchy信息</summary>
        public abstract int Edit(int ID, Guid DimIdx, string ItemName, int PID, int DisplayOrder);
        /// <summary>根据PK_DimHierarchy删除DimHierarchy信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据FK_OA_HIERARCHY_REF_DIM删除DimHierarchy信息</summary>
        public abstract int DelDim(Guid DimIdx);
        #endregion
    }
}
#endregion
// 级联项目辅助(Von_DimHierarchySubsidiary)
#region "级联项目辅助接口声明"
namespace Von.Web.Apis
{
    public interface DimHierarchySubsidiaryInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>项目序号</summary>
        int ItemIdx { get; set; }
        /// <summary>附属名称</summary>
        string SubsidiaryName { get; set; }
        /// <summary>辅助内容</summary>
        string Content { get; set; }
        #endregion
    }
}
#endregion
#region "级联项目辅助信息声明"
namespace Von.Web.Structs
{
    public class DimHierarchySubsidiaryInfo : DimHierarchySubsidiaryInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public DimHierarchySubsidiaryInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="ItemIdx">项目序号</param>
        /// <param name="SubsidiaryName">附属名称</param>
        /// <param name="Content">辅助内容</param>
        public DimHierarchySubsidiaryInfo(int ID, int ItemIdx, string SubsidiaryName, string Content)
        {
            this.ID = ID;
            this.ItemIdx = ItemIdx;
            this.SubsidiaryName = SubsidiaryName;
            this.Content = Content;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "级联项目辅助")]
        public int ID { get; set; } = 0;
        /// <summary>项目序号</summary>
        [Required]
        [LocalDisplay("项目序号", "级联项目辅助")]
        public int ItemIdx { get; set; } = 0;
        /// <summary>附属名称</summary>
        [Required]
        [LocalDisplay("附属名称", "级联项目辅助")]
        public string SubsidiaryName { get; set; } = "";
        /// <summary>辅助内容</summary>
        [LocalDisplay("辅助内容", "级联项目辅助")]
        public string Content { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "级联项目辅助信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>级联项目辅助 控制类</summary>
    /// <seealso cref="ZTY.OA.Models.DimHierarchySubsidiaryInfo"/>
    public class DimHierarchySubsidiaryTask
    {
        protected DimHierarchySubsidiaryAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public DimHierarchySubsidiaryTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<DimHierarchySubsidiaryAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, DimHierarchySubsidiaryInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.ItemIdx = (int)reader["ItemIdx"];  //项目序号
            info.SubsidiaryName = (string)reader["SubsidiaryName"];  //附属名称
            info.Content = (string)reader["Content"];  //辅助内容
        }
        /// <summary>检验DimHierarchySubsidiary信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : DimHierarchySubsidiaryInterface, new()
        {
            /// <summary>根据索引 IDX_DimHierarchySubsidiary 提取信息</summary>
            if (info.ItemIdx == 0) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "项目序号");
            /// <summary>根据索引 IDX_DimHierarchySubsidiary 提取信息</summary>
            if (string.IsNullOrEmpty(info.SubsidiaryName)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "附属名称");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_DimHierarchySubsidiary 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByDimHierarchySubsidiary<T>(int ID) where T : DimHierarchySubsidiaryInfo, new()
        {
            IDataReader reader = dbAccess.GetByDimHierarchySubsidiary(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 级联项目辅助 信息</summary>
        public async Task<List<T>> List<T>(int ItemIdx) where T : DimHierarchySubsidiaryInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List(ItemIdx);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据索引 IDX_DimHierarchySubsidiary 提取信息</summary>
        /// <param name="ItemIdx">项目序号</param>
        /// <param name="SubsidiaryName">附属名称</param>
        public async Task<DimHierarchySubsidiaryInfo> GetByDimHierarchySubsidiary(int ItemIdx, string SubsidiaryName)
        {
            IDataReader reader = dbAccess.GetByDimHierarchySubsidiary(ItemIdx, SubsidiaryName);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            DimHierarchySubsidiaryInfo info = new DimHierarchySubsidiaryInfo();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>自定义查询DimHierarchySubsidiary信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : DimHierarchySubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>保存DimHierarchySubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Save<T>(T info) where T : DimHierarchySubsidiaryInfo, new()
        {
            if (info.ID == 0) return await Add(info);
            else return await Edit(info);
        }
        /// <summary>添加DimHierarchySubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(DimHierarchySubsidiaryInfo info)
        {
            info.ID = dbAccess.Add(info.ItemIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("添加级联项目辅助{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改DimHierarchySubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(DimHierarchySubsidiaryInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.ItemIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("修改级联项目辅助{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_DimHierarchySubsidiary删除DimHierarchySubsidiary信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_DimHierarchySubsidiary删除级联项目辅助{0}", ID);
            return effect > 0;
        }
        /// <summary>根据Reference_57删除DimHierarchySubsidiary信息</summary>
        ///<param name="ItemIdx">项目序号</param>
        public async Task<bool> DelItem(int ItemIdx)
        {
            int effect = dbAccess.DelItem(ItemIdx);
            Runtime.Log.InfoFormat("根据Reference_57删除级联项目辅助{0}", ItemIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "级联项目辅助信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="ZTY.OA.Models.DimHierarchySubsidiaryInfo"/>
    /// <seealso cref="ZTY.OA.Operators.DimHierarchySubsidiaryCtrl"/>
    public abstract class DimHierarchySubsidiaryAccess : DBAccessBase
    {
        #region "DimHierarchySubsidiary Abstract Methods"
        /// <summary>根据主键 PK_DimHierarchySubsidiary 提取信息</summary>
        ///<param name="ID">序号</param>
        public abstract IDataReader GetByDimHierarchySubsidiary(int ID);
        /// <summary>提取 级联项目辅助 列表</summary>
        public abstract IDataReader List(int ItemIdx);
        /// <summary>查询 级联项目辅助 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据主键 IDX_DimHierarchySubsidiary 提取信息</summary>
        public abstract IDataReader GetByDimHierarchySubsidiary(int ItemIdx, string SubsidiaryName);
        /// <summary>添加DimHierarchySubsidiary信息</summary>
        public abstract int Add(int ItemIdx, string SubsidiaryName, string Content);
        /// <summary>修改DimHierarchySubsidiary信息</summary>
        public abstract int Edit(int ID, int ItemIdx, string SubsidiaryName, string Content);
        /// <summary>根据PK_DimHierarchySubsidiary删除DimHierarchySubsidiary信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据Reference_57删除DimHierarchySubsidiary信息</summary>
        public abstract int DelItem(int ItemIdx);
        #endregion
    }
}
#endregion
// 编码项目(Von_EncodingItem)
#region "编码项目接口声明"
namespace Von.Web.Apis
{
    public interface EncodingItemInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>所属维度</summary>
        Guid DimIdx { get; set; }
        /// <summary>编码</summary>
        string Code { get; set; }
        /// <summary>基础编码</summary>
        string PID { get; set; }
        /// <summary>项目名称</summary>
        string ItemName { get; set; }
        #endregion
    }
}
#endregion
#region "编码项目信息声明"
namespace Von.Web.Structs
{
    public class EncodingItemInfo : EncodingItemInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public EncodingItemInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="DimIdx">所属维度</param>
        /// <param name="Code">编码</param>
        /// <param name="PID">基础编码</param>
        /// <param name="ItemName">项目名称</param>
        public EncodingItemInfo(int ID, Guid DimIdx, string Code, string PID, string ItemName)
        {
            this.ID = ID;
            this.DimIdx = DimIdx;
            this.Code = Code;
            this.PID = PID;
            this.ItemName = ItemName;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "编码项目")]
        public int ID { get; set; } = 0;
        /// <summary>所属维度</summary>
        [Required]
        [LocalDisplay("所属维度", "编码项目")]
        public Guid DimIdx { get; set; } = Guid.NewGuid();
        /// <summary>编码</summary>
        [LocalDisplay("编码", "编码项目")]
        public string Code { get; set; } = "";
        /// <summary>基础编码</summary>
        [LocalDisplay("基础编码", "编码项目")]
        public string PID { get; set; } = "";
        /// <summary>项目名称</summary>
        [LocalDisplay("项目名称", "编码项目")]
        public string ItemName { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "编码项目扩展信息"
namespace Von.Web.Models
{
    public class EncodingItemTree : EncodingItemInfo
    {
        /// <summary>，'open' 或 'closed'，默认是 'open'。当设置为 'closed' 时，该节点有子节点，并且将从远程站点加载它们</summary>
        public string state { get => (children == null || children.Count == 0) ? "open" : "closed"; }
        public string text { get { return ItemName; } }
        /// <summary>指示节点是否被选中</summary>
        public bool Checked { get; set; }
        /// <summary>给一个节点添加的自定义属性</summary>
        public string attributes { get; set; }
        public List<EncodingItemTree> children { get; set; }
    }
}
#endregion  
#region "编码项目信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>编码项目 控制类</summary>
    /// <seealso cref="ZTY.OA.Models.EncodingItemInfo"/>
    public class EncodingItemTask
    {
        protected EncodingItemAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public EncodingItemTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<EncodingItemAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, EncodingItemInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.DimIdx = (Guid)reader["DimIdx"];  //所属维度
            info.Code = (string)reader["Code"];  //编码
            info.PID = (string)reader["PID"];  //基础编码
            info.ItemName = (string)reader["ItemName"];  //项目名称
        }
        /// <summary>检验EncodingItem信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : EncodingItemInterface, new()
        {
            /// <summary>根据索引 IDX_DimEncodingItem 提取信息</summary>
            if (info.DimIdx == Guid.Empty) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "所属维度");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_EncodingItem 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByEncodingItem<T>(int ID) where T : EncodingItemInfo, new()
        {
            IDataReader reader = dbAccess.GetByEncodingItem(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>
        /// 根据主键 PK_EncodingItem 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByEncodingItem<T>(Guid DimIdx, string Code) where T : EncodingItemInfo, new()
        {
            IDataReader reader = dbAccess.GetByEncodingItem(DimIdx, Code);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>自定义查询EncodingItem信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : EncodingItemInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>提取Tree结构信息</summary>
        public async Task<List<EncodingItemTree>> TreeEncodingItem(Guid DimIdx, string PID, bool hasChildren)
        {
            List<EncodingItemTree> tree = new List<EncodingItemTree>();
            IDataReader reader = dbAccess.ListByDimEncodingItem(DimIdx, PID);
            while (reader.Read())
            {
                EncodingItemTree info = new EncodingItemTree();
                setInfoValue(reader, info);
                tree.Add(info);
                if (hasChildren)
                    info.children = await TreeEncodingItem(DimIdx, info.Code, hasChildren);
            }
            reader.Close();
            return tree;
        }
        /// <summary>根据外键 FK_OA_ENCODING_REF_DIMENSION 提取信息</summary>
        public async Task<List<T>> List<T>(Guid DimIdx, string PID) where T : EncodingItemInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByDimEncodingItem(DimIdx, PID);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>保存EncodingItem信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Save<T>(T info) where T : EncodingItemInfo, new()
        {
            if (info.ID == 0) return await Add(info);
            else return await Edit(info);
        }
        /// <summary>添加EncodingItem信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(EncodingItemInfo info)
        {
            info.ID = dbAccess.Add(info.DimIdx, info.Code, info.PID, info.ItemName);
            Runtime.Log.InfoFormat("添加编码项目{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改EncodingItem信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(EncodingItemInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.DimIdx, info.Code, info.PID, info.ItemName);
            Runtime.Log.InfoFormat("修改编码项目{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_EncodingItem删除EncodingItem信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_EncodingItem删除编码项目{0}", ID);
            return effect > 0;
        }
        /// <summary>根据FK_OA_ENCODING_REF_DIMENSION删除EncodingItem信息</summary>
        ///<param name="DimIdx">所属维度</param>
        public async Task<bool> DelDim(Guid DimIdx)
        {
            int effect = dbAccess.DelDim(DimIdx);
            Runtime.Log.InfoFormat("根据FK_OA_ENCODING_REF_DIMENSION删除编码项目{0}", DimIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "编码项目信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="ZTY.OA.Models.EncodingItemInfo"/>
    /// <seealso cref="ZTY.OA.Operators.EncodingItemCtrl"/>
    public abstract class EncodingItemAccess : DBAccessBase
    {
        #region "EncodingItem Abstract Methods"
        /// <summary>根据主键 PK_EncodingItem 提取信息</summary>
        ///<param name="ID">序号</param>
        public abstract IDataReader GetByEncodingItem(int ID);
        /// <summary>查询 编码项目 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据主键 IDX_DimEncodingItem 提取信息</summary>
        public abstract IDataReader ListByDimEncodingItem(Guid DimIdx, string PID);
        /// <summary>添加EncodingItem信息</summary>
        public abstract int Add(Guid DimIdx, string Code, string PID, string ItemName);
        /// <summary>修改EncodingItem信息</summary>
        public abstract int Edit(int ID, Guid DimIdx, string Code, string PID, string ItemName);
        /// <summary>根据PK_EncodingItem删除EncodingItem信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据FK_OA_ENCODING_REF_DIMENSION删除EncodingItem信息</summary>
        public abstract int DelDim(Guid DimIdx);
        public abstract IDataReader GetByEncodingItem(Guid dimIdx, string code);
        #endregion
    }
}
#endregion
// 编码项目辅助(Von_EncodingItemSubsidiary)
#region "编码项目辅助接口声明"
namespace Von.Web.Apis
{
    public interface EncodingItemSubsidiaryInterface
    {
        #region "Properties"
        /// <summary>序号</summary>
        int ID { get; set; }
        /// <summary>所属项目</summary>
        int ItemIdx { get; set; }
        /// <summary>附属名称</summary>
        string SubsidiaryName { get; set; }
        /// <summary>辅助内容</summary>
        string Content { get; set; }
        #endregion
    }
}
#endregion
#region "编码项目辅助信息声明"
namespace Von.Web.Structs
{
    public class EncodingItemSubsidiaryInfo : EncodingItemSubsidiaryInterface
    {
        #region "Constructors"
        /// <summary>
        /// 构造函数
        /// </summary>
        public EncodingItemSubsidiaryInfo()
        {
        }
        /// <summary>
        /// 含初始化构造函数
        /// </summary>
        /// <param name="ID">序号</param>
        /// <param name="ItemIdx">所属项目</param>
        /// <param name="SubsidiaryName">附属名称</param>
        /// <param name="Content">辅助内容</param>
        public EncodingItemSubsidiaryInfo(int ID, int ItemIdx, string SubsidiaryName, string Content)
        {
            this.ID = ID;
            this.ItemIdx = ItemIdx;
            this.SubsidiaryName = SubsidiaryName;
            this.Content = Content;
        }
        #endregion
        #region "Properties"
        /// <summary>序号</summary>
        [Required]
        [LocalDisplay("序号", "编码项目辅助")]
        public int ID { get; set; } = 0;
        /// <summary>所属项目</summary>
        [Required]
        [LocalDisplay("所属项目", "编码项目辅助")]
        public int ItemIdx { get; set; } = 0;
        /// <summary>附属名称</summary>
        [Required]
        [LocalDisplay("附属名称", "编码项目辅助")]
        public string SubsidiaryName { get; set; } = "";
        /// <summary>辅助内容</summary>
        [LocalDisplay("辅助内容", "编码项目辅助")]
        public string Content { get; set; } = "";
        #endregion
    }
}
#endregion    
#region "编码项目辅助信息基础控制类声明"
namespace Von.Web.Tasks
{
    /// <summary>编码项目辅助 控制类</summary>
    /// <seealso cref="ZTY.OA.Models.EncodingItemSubsidiaryInfo"/>
    public class EncodingItemSubsidiaryTask
    {
        protected EncodingItemSubsidiaryAccess dbAccess = null;
        /// <summary>含数据库事务的构造函数</summary>
        public EncodingItemSubsidiaryTask(DbTransaction DBTrans = null)
        {
            dbAccess = Statement.App.GetAccess<EncodingItemSubsidiaryAccess>(DBTrans);
        }
        //Read data and write to AgentInfo class
        protected void setInfoValue(IDataReader reader, EncodingItemSubsidiaryInterface info)
        {
            info.ID = (int)reader["ID"];  //序号
            info.ItemIdx = (int)reader["ItemIdx"];  //所属项目
            info.SubsidiaryName = (string)reader["SubsidiaryName"];  //附属名称
            info.Content = (string)reader["Content"];  //辅助内容
        }
        /// <summary>检验EncodingItemSubsidiary信息</summary>
        public async Task<ExecuteResult> Check<T>(T info) where T : EncodingItemSubsidiaryInterface, new()
        {
            if (info.ID == 0) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "序号");
            /// <summary>根据索引 IDX_EncodingItemSubsidiary 提取信息</summary>
            if (info.ItemIdx == 0) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "所属项目");
            /// <summary>根据索引 IDX_EncodingItemSubsidiary 提取信息</summary>
            if (string.IsNullOrEmpty(info.SubsidiaryName)) return ExecuteResult.Failed(Statement.App.ResxName, "1001", "附属名称");
            return ExecuteResult.Success(true);
        }
        /// <summary>
        /// 根据主键 PK_EncodingItemSubsidiary 提取信息
        /// </summary>
        /// <param name="ID">序号</param>
        public async Task<T> GetByEncodingItemSubsidiary<T>(int ID) where T : EncodingItemSubsidiaryInfo, new()
        {
            IDataReader reader = dbAccess.GetByEncodingItemSubsidiary(ID);
            if (!reader.Read())
            {
                reader.Close();
                return null;
            }
            T info = new T();
            setInfoValue(reader, info);
            reader.Close();
            return info;
        }
        /// <summary>提取所有 编码项目辅助 信息</summary>
        public async Task<List<T>> List<T>() where T : EncodingItemSubsidiaryInterface, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.List();
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>自定义查询EncodingItemSubsidiary信息</summary>
        /// <param name="ConditionJson">查询条件</param>
        /// <remarks>
        ///   <para>ConditionJson是查询条件参数，是JObject存储的JSON格式数据，格式是[fieldname]=[条件值]，系统支持层架JSON架构</para>
        ///   <para>[fieldname]的首字母如果是下划线，表明为或条件，没有则是与条件</para>
        ///   <para>[fieldname]的尾字母如果是0，表明为 等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是1，表明为 大于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是2，表明为 小于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是3，表明为 LIKE 条件值%</para>
        ///   <para>[fieldname]的尾字母如果是4，表明为 LIKE %条件值%</para>
        ///   <para>[fieldname]的尾字母如果是5，表明为 LIKE %条件值</para>
        ///   <para>[fieldname]的尾字母如果是6，表明为 小于等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是7，表明为 大于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是8，表明为 不等于 条件值</para>
        ///   <para>[fieldname]的尾字母如果是9，表明为 IN 条件值</para>
        ///   <para>[fieldname]的尾字母是非数字，表明为 等于 条件值</para>
        /// </remarks>
        /// <example>
        ///   {key0:val1, fieldA1:val2, _A:{fieldC4:val3, fieldD7:val4} }
        ///   AND key=val1 AND fieldA>=val2 OR (fieldC LIKE %val3% AND fieldD>val2)
        /// </example>
        public async Task<List<T>> Search<T>(JObject ConditionJson) where T : EncodingItemSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.Search(ConditionJson);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>根据外键 FK_OA_SUBSIDIARY_REF_ENCODING 提取信息</summary>
        public async Task<List<T>> ListByOA_SUBSIDIARY_REF_ENCODING<T>(int ItemIdx) where T : EncodingItemSubsidiaryInfo, new()
        {
            List<T> list = new List<T>();
            IDataReader reader = dbAccess.ListByOA_SUBSIDIARY_REF_ENCODING(ItemIdx);
            while (reader.Read())
            {
                T info = new T();
                setInfoValue(reader, info);
                list.Add(info);
            }
            reader.Close();
            return list;
        }
        /// <summary>添加EncodingItemSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Add(EncodingItemSubsidiaryInfo info)
        {
            info.ID = dbAccess.Add(info.ID, info.ItemIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("添加编码项目辅助{0}", info.ID);
            return info.ID > 0;
        }
        /// <summary>修改EncodingItemSubsidiary信息</summary>
        ///<param name="info">信息类</param>
        public async Task<bool> Edit(EncodingItemSubsidiaryInfo info)
        {
            int effect = dbAccess.Edit(info.ID, info.ItemIdx, info.SubsidiaryName, info.Content);
            Runtime.Log.InfoFormat("修改编码项目辅助{0}", info.ID);
            return effect > 0;
        }
        /// <summary>根据PK_EncodingItemSubsidiary删除EncodingItemSubsidiary信息</summary>
        /// <param name="ID">序号</param>
        public async Task<bool> Del(int ID)
        {
            int effect = dbAccess.Del(ID);
            Runtime.Log.InfoFormat("根据PK_EncodingItemSubsidiary删除编码项目辅助{0}", ID);
            return effect > 0;
        }
        /// <summary>根据FK_OA_SUBSIDIARY_REF_ENCODING删除EncodingItemSubsidiary信息</summary>
        ///<param name="ItemIdx">所属项目</param>
        public async Task<bool> DelItem(int ItemIdx, string SubsidiaryName)
        {
            int effect = dbAccess.DelItem(ItemIdx, SubsidiaryName);
            Runtime.Log.InfoFormat("根据FK_OA_SUBSIDIARY_REF_ENCODING删除编码项目辅助{0}", ItemIdx);
            return effect > 0;
        }
    }
}
#endregion
#region "编码项目辅助信息数据库访问基类声明"
namespace Von.Web.Datas
{
    /// <summary>
    /// 数据及操作控制层
    /// </summary>
    /// <seealso cref="ZTY.OA.Models.EncodingItemSubsidiaryInfo"/>
    /// <seealso cref="ZTY.OA.Operators.EncodingItemSubsidiaryCtrl"/>
    public abstract class EncodingItemSubsidiaryAccess : DBAccessBase
    {
        #region "EncodingItemSubsidiary Abstract Methods"
        /// <summary>根据主键 PK_EncodingItemSubsidiary 提取信息</summary>
        ///<param name="ID">序号</param>
        public abstract IDataReader GetByEncodingItemSubsidiary(int ID);
        /// <summary>提取 编码项目辅助 列表</summary>
        public abstract IDataReader List();
        /// <summary>查询 编码项目辅助 列表</summary>
        public abstract IDataReader Search(JObject ConditionJson);
        /// <summary>根据主键 IDX_EncodingItemSubsidiary 提取信息</summary>
        public abstract IDataReader ListByEncodingItemSubsidiary(int ItemIdx, string SubsidiaryName);
        /// <summary>根据外键 FK_OA_SUBSIDIARY_REF_ENCODING 提取信息</summary>
        public abstract IDataReader ListByOA_SUBSIDIARY_REF_ENCODING(int ItemIdx);
        /// <summary>添加EncodingItemSubsidiary信息</summary>
        public abstract int Add(int ID, int ItemIdx, string SubsidiaryName, string Content);
        /// <summary>修改EncodingItemSubsidiary信息</summary>
        public abstract int Edit(int ID, int ItemIdx, string SubsidiaryName, string Content);
        /// <summary>根据PK_EncodingItemSubsidiary删除EncodingItemSubsidiary信息</summary>
        public abstract int Del(int ID);
        /// <summary>根据FK_OA_SUBSIDIARY_REF_ENCODING删除EncodingItemSubsidiary信息</summary>
        public abstract int DelItem(int ItemIdx, string SubsidiaryName);
        #endregion
    }
}
#endregion
#endregion